First of all, you can get the current datetime using getdate() and user name using system_user.If you are using stored procedure to insert and update records into your table at all times, you can code it in your stored procedure-- insertinsert into table1( . . . [datecol], [usercol])select . . . getdate(), system_user-- updateupdate tset . . . , [datecol] = getdate(), [userocl] = system_userfrom table1 t
You can also do it in your table definition during creation. This will only update during record insertioncreate table1( . . . [datecol] datetime default getdate(), [usercol] varchar(100) default system_user, . . . )
With the default value, you may omit the 2 column in your insert statement. If you did not omit this 2 columns in your insert statement, you need to pass in the correct value and not NULL value. But that does not take care of the update statement. If you don't have a stored procedure to perform the update to the table, you can use an update trigger to do the jobupdate uset [datecol] = getdate(), [usercol] = system_userfrom inserted i inner join table1 u on i.pkcol = u.pkcol
KH[spoiler]Time is always against us[/spoiler]