|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
default column valueHere's the example in 2005 Books Online. The date_ins GETDATE() is the one
you need. CREATE TABLE test_defaults (keycol smallint, process_id smallint DEFAULT @@SPID, --Preferred default definition date_ins datetime DEFAULT getdate(), --Preferred default definition mathcol smallint DEFAULT 10 * 2, --Preferred default definition char1 char(3), char2 char(3) DEFAULT 'xyz') --Preferred default definition; GO -- Show quoteHTH. Ryan "gary" <ad***@newsgroup.com.hk> wrote in message news:eHFDHarEGHA.3100@tk2msftngp13.phx.gbl... > as current time.. > how can i set that in mssql 2005 ? > Note that naming constraints is considered good practice. Sooner or later you will want to change
some defaults, and if you don't know the name, you have to look up the auto-generated name in the system tables. This makes implementation of such scripts a mess. -- Show quoteTibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ Blog: http://solidqualitylearning.com/blogs/tibor/ "Ryan" <Ryan_Waight@nospam.hotmail.com> wrote in message news:uwM3JhrEGHA.916@TK2MSFTNGP10.phx.gbl... > Here's the example in 2005 Books Online. The date_ins GETDATE() is the one you need. > > CREATE TABLE test_defaults > (keycol smallint, > process_id smallint DEFAULT @@SPID, --Preferred default definition > date_ins datetime DEFAULT getdate(), --Preferred default definition > mathcol smallint DEFAULT 10 * 2, --Preferred default definition > char1 char(3), > char2 char(3) DEFAULT 'xyz') --Preferred default definition; > GO > > > -- > HTH. Ryan > > > "gary" <ad***@newsgroup.com.hk> wrote in message news:eHFDHarEGHA.3100@tk2msftngp13.phx.gbl... >> as current time.. >> how can i set that in mssql 2005 ? >> > > |
|||||||||||||||||||||||