Skip to content Skip to sidebar Skip to footer

Automatically Inserting Datetime With Insert

I have a radgrid with the setup below. I'm able to properly insert a new row into my table but the Time_Stamp column still shows as NULL. Datatype is datetime in the database. I've

Solution 1:

You could set up your TIME_STAMP column to have a default constraint that would set the current date and time automatically when a new row is inserted:

ALTERTABLE dbo.ProviderValueCard
ADDCONSTRAINT DF_ProviderValueCard_Time_Stamp
   DEFAULT (SYSDATETIME()) FOR TIME_STAMP

Now, every time a row is inserted and no value is provided from the front-end, SQL Server will fill in the current date & time into TIME_STAMP automagically :-)

Post a Comment for "Automatically Inserting Datetime With Insert"