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 |
|
allan8964
Posting Yak Master
249 Posts |
Posted - 2012-03-15 : 09:35:43
|
| Hi there,I wonder if it's possible to keep the record of an author in a col. For example, in table1 I have cols:tableID | Event | Date | Author |...I know I can set Date as Getdate() by constraint or a trigger, further I need Author col populated automatically by the userAcct who insert, edit or delete the row. Is this possible? Thanks in advance. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2012-03-15 : 09:54:26
|
Set USER_NAME() and GETDATE() as default values. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
allan8964
Posting Yak Master
249 Posts |
Posted - 2012-03-15 : 10:18:14
|
| Thanks SwePeso. But I tried select user_name(), it returns dbo, not a user acct. I need exact user name or acct name. Thanks |
 |
|
|
allan8964
Posting Yak Master
249 Posts |
Posted - 2012-03-15 : 10:27:01
|
| Did some research and found that user_name(id) returns impersonated info without id added, fro automatically added user we can use defaut with current_user set on the column of author. Thanks. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-03-15 : 11:36:48
|
select system_user KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
allan8964
Posting Yak Master
249 Posts |
Posted - 2012-03-15 : 12:54:10
|
| oh yeah, you're so good. It returns the user account with domain name. that's exactly what I'm looking for! THANKS!!! |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|