Solved

notify sql_users when certain user insert adata in atable

Posted on 2002-06-11
3
177 Views
Last Modified: 2012-06-21
hi every body
iam useing ms_sql 7 server in windows nt .04 network(lan).
iwant to notify four sql user in my net work when acertain user insert a data in acertain table , acsually isucesseded to notify them useing the stored procedure (xp_cmdshell) that is to say when any user update or insert adata in my table i get amessage , but idont know whow can i make this message when acertain user insert or update the table
0
Comment
Question by:bahamo
3 Comments
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 7069412
create a trigger on the table you want, and use system_user variable to determine who is inserting a record to the table. Then execute xp_cmdshell 'net send' to send a message to whoever you want to be notified.
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 200 total points
ID: 7070087
You can check for a certain user by using SUSER_SNAME().  For example:

IF SUSER_SNAME() = 'anyDomain\user01' --for domain account
--or IF SUSER_SNAME() = 'sqlUser01'
BEGIN
    EXEC xp_cmdshell ... --msg to user1
    EXEC xp_cmdshell ... --msg to user2
    EXEC xp_cmdshell ... --msg to user3
    EXEC xp_cmdshell ... --msg to user4
END --IF
0
 

Author Comment

by:bahamo
ID: 7091910
hi,,
thank you very much for avaluable information you give to me which help me solving my problem concerning notifing sql users over my network useing net sen
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question