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 |
|
skillile
Posting Yak Master
208 Posts |
Posted - 2003-02-27 : 10:23:44
|
| I have a table with an after delete trigger. My delete looks something like this...proc ps_delete(@userid ..,@rectodel ..)asdelete from table where rec = rec...anyway i want to be able to send the @userid into the trigger to add history is there a way to capture that value and pass or access that.Thanksslow down to move faster... |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-02-27 : 10:41:04
|
| You can't pass a value to a trigger.You can access user_name() and system_user if this is how you identify the user.You can also put the spid on a user table when the user logs in for a client server app or for every connection if it's not and query the table using @@spid.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-02-27 : 11:08:36
|
| Or you can do:In your sproc:DECLARE @BinVar varbinary(128)SET @BinVar = CAST( REPLICATE( 0x20, 128 ) AS varbinary(128) )select @BinVar = convert(varbinary(128),@User_Id)SET CONTEXT_INFO @BinVarIn Your TriggerDeclare @DelBY char(8)SELECT @DelBY = CASE WHEN ASCII(context_info) <> 0 THEN convert(varchar(8),context_info) ELSE 'EXTERNAL' ENDFROM master.dbo.sysprocesses WHERE spid = @@SPIDGood LuckBrett8-) |
 |
|
|
|
|
|