Here’s the generated script from SSMS “Script Table as”->”Create To”:
USE [DADatabaseMarch11]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LoginName](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](255) NOT NULL,
CONSTRAINT [PK_LoginName] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT [IX_LoginName] UNIQUE NONCLUSTERED
(
[name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
I am using SQL 2008 R2 only without any need for backward compatability.
My QUESTION is: are there pieces of the above that, for practical purposes, can be left out?
ANSI_NULLS http://msdn.microsoft.com/en-us/library/ms188048.aspx
You are not doing anything special with filtered indexes, computed columns etc, so you can drop it.
QUOTED_IDENTIFIER http://msdn.microsoft.com/en-us/library/ms174393.aspx
Very standard names with nary a quote in sight, so it has zero effect here.
ANSI_PADDING http://msdn.microsoft.com/en-us/library/ms187403.aspx
This setting should invariably be on. It is only needed here if you have for whatever reason you have set it to off. Even then, it does not do much, because even if you kept trailing spaces in LoginName.NAME,
Because throughout SQL Server, it is already doing funny things with trailing spaces.
The bare minimum you need
dbo.in there, but to be honest, it can go too in 99% of cases