Pick up a good practice: Best Practice: Naming Constraints


http://blogs.msdn.com/b/dtjones/archive/2009/10/29/best-practice-naming-constraints.aspx

Instead of using the System Named Constraint, it is good practice to use Programmer Named Constraint.



CREATE TABLE dbo.testdt ( testdt datetime CONSTRAINT DF_defaultDT DEFAULT (getdate()) ) 


 

 --Script from SSMS

 CREATE TABLE [dbo].[testdt](
	[testdt] [datetime] NULL
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[testdt] ADD  CONSTRAINT [DF_defaultDT]  DEFAULT (getdate()) FOR [testdt]
GO



 
Advertisements


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s