SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 MS SQL Delete Trigger session variable
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kok_sheng2000
Starting Member

10 Posts

Posted - 05/15/2012 :  00:20:18  Show Profile  Reply with Quote
Hi, Everyone.

I want to keep the log detail for my record
in MS SQL Database when user Delete a record.
So I have a SQL Trigger Delete Function in related Table.
What I want to keep is the User Name From My Software's User
who delete the record, But i have no any field keep in the table,
Is that MS SQL have any session variable or temp variable that
can let my system to update and run at once together with Trigger Delete and
so keep in the log detail table ?

visakh16
Very Important crosS Applying yaK Herder

India
47069 Posts

Posted - 05/15/2012 :  00:44:16  Show Profile  Reply with Quote
make use of SUSER_SNAME() function to get username

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

kok_sheng2000
Starting Member

10 Posts

Posted - 05/15/2012 :  00:51:10  Show Profile  Reply with Quote
Hi, visakh16, Thanks For Reply .
I want the user name from my software login user name not the
MS SQL Login User name. I Means a variable user name send from my program
during Delete Operation. Tq
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47069 Posts

Posted - 05/15/2012 :  01:13:28  Show Profile  Reply with Quote
quote:
Originally posted by kok_sheng2000

Hi, visakh16, Thanks For Reply .
I want the user name from my software login user name not the
MS SQL Login User name. I Means a variable user name send from my program
during Delete Operation. Tq


do you've a table storing those usernames in sql server? or is it domain username?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

kok_sheng2000
Starting Member

10 Posts

Posted - 05/15/2012 :  01:21:25  Show Profile  Reply with Quote
My Program Current Login Username, I have keep it Database,
But The problem is :-
1> There are multi-user login at a time.
2> During Trigger Delete, username that delete not send to trigger.
So, What i want to know is, how or any other way to Send / communicate
with Trigger Delete when a user delete a record. Thank in advanced ...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47069 Posts

Posted - 05/15/2012 :  22:09:18  Show Profile  Reply with Quote
quote:
Originally posted by kok_sheng2000

My Program Current Login Username, I have keep it Database,
But The problem is :-
1> There are multi-user login at a time.
2> During Trigger Delete, username that delete not send to trigger.
So, What i want to know is, how or any other way to Send / communicate
with Trigger Delete when a user delete a record. Thank in advanced ...


you've capture and send that information manually unless its not a domain or standard sql user

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

kok_sheng2000
Starting Member

10 Posts

Posted - 05/16/2012 :  21:46:24  Show Profile  Reply with Quote
Oop, is like that , then no choice ... Thanks for help me ...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47069 Posts

Posted - 05/16/2012 :  21:49:42  Show Profile  Reply with Quote
np

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000