Setting up AutoInsert

  • 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

  • removed by submiitter

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply