A really simple bug with SSMS

If you’re a long time IT professional or an occasional user of high or even low tech software you’ll know what I mean when I say “Bugs are not a new thing”.

Some bugs are earth shattering others are an annoyance and some just make you chuckle. Luckily this simple bug is not earth shattering or annoying.

Have you ever scripted an object from SQL Server Management Studio (SSMS)? It does a really good job. You get nice cleanly formatted scripts that start with USE statements to select the database. They even have some simple comments?

Have you ever written a Sequence? Turns out if you script one you’ll notice that Microsoft left you an extra surprise. Double USE statements. Does it matter much? No. Should they fix it? Yes. I noticed this behavior when sequences were first released and it still exists in the latest version of SSMS for SQL 2016 (13.0.1500.23) as of this posting.

To script an object, navigate to it in Object Explorer. Right click and choose any option in the “Script object as” submenu.

Here’s a sample object scripted:

USE [Billing]
GO

/****** Object:  Table [dbo].[appConfig]    Script Date: 9/27/2016 9:47:45 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[appConfig](
[ConfigType] [varchar](50) NULL,
[ConfigValue] [varchar](50) NULL
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

Notice the single USE statement at the top?

Now let’s look at a sequence.

USE [Billing]
GO

USE [Billing]
GO

/****** Object:  Sequence [dbo].[SeqCommodityID]    Script Date: 9/27/2016 9:37:37 PM ******/
CREATE SEQUENCE [dbo].[SeqCommodityID]
AS [bigint]
START WITH 17
INCREMENT BY 1
MINVALUE 1
MAXVALUE 9223372036854775807
CACHE
GO

Two USE statements. Again, this isn’t doing any harm so I can imagine it’s really low on the priority; though, it does seem like an issue that they could fix in about 10 minutes. After two versions, I wonder if they will.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s