Does anyone know of a function as such that I can use to add an automatic date and timestamp in a column for when a user adds a record to the database table?
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
You can pass
GetDate()
function as an parameter to your insert query e.gYou can use a
datetime
field and set it's default value toGetDate()
.You can create a non-nullable DATETIME column on your table, and create a DEFAULT constraint on it to auto populate when a row is added.
e.g.
You can make a default constraint on this column that will put a default getdate() as a value.
Example:
you can use DateAdd on a trigger or a computed column if the timestamp you are adding is fixed or dependent of another column