January 19, 2010 at 11:29 am
I've got a field "DateCreated" in a table and whenever new records are inserted into this table this field needs to auto insert the DateTime. So, how do I set up the field to AutoInsert if I don't want to have to pass it such in the code below:
INSERT INTO [DATABASE].[DBO].[rs_RNWOFR_TouchPointHistory]
([MailYear], [MailMonth], [MKTCode], [CustomerNo], [Customer_Type], [Expiration_Roman], [DateCreated])
SELECT DATEPART(yy,GetDate()) MailYear, DATEPART(m,GetDate()) MailMonth,
[$9MKT], CustomerNo, Customer_Type, dbo.ConvJulian2(Expires) Expiration_roman, GetDate() DateCreated
FROM email_tmpRNWOFR_2010
thx,
John
January 19, 2010 at 12:24 pm
January 19, 2010 at 12:31 pm
You need to set a default on the column. Look up ALTER TABLE for the syntax to do so.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply