Friday, February 24, 2012

Auto-generating a DateTime in SQL Server Express 2005

Is it possible to have a DateTime field in a row automatically generated when a row is created?

ie:

INSERT INTO [TableName] ([DateTimeStamp], [UserId], [Title], [Explanation]) VALUES (DateTime.Now(), @.UserId, @.Title, @.Explanation)

or something like that?

You can set up a default value of GetDate() to the column in the design view of the table.

|||

Thanks! Exactly the solution I was looking for.

No comments:

Post a Comment