Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dewacorp.alliances
452 Posts |
Posted - 2005-07-22 : 03:09:05
|
| Hi everyoneI'm creating fields on one of my table to track who is modified and created the records. I'm thinking to use trigger as I did for DateModified field. But I am not sure how you can get the login database that who's trying modify that table. Is there any SQL in-built function for this?Any help regarding I'm really appreciated that.Thanks |
|
|
emilg
Starting Member
13 Posts |
Posted - 2005-07-22 : 03:54:03
|
You can use the function USER_NAME().For reducing overhead instead of a FOR INSERT trigger you can use USER or CURRENT_USER with DEFAULT constraints (see BOL).CREATE TABLE inventory2( part_id int IDENTITY(100, 1) NOT NULL, description varchar(30) NOT NULL, entry_person varchar(30) NOT NULL DEFAULT USER ) |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-07-22 : 04:44:43
|
| use system_user instead to get the actual login used.--------------------keeping it simple... |
 |
|
|
|
|
|