Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

notify sql_users when certain user insert adata in atable

Posted on 2002-06-11
3
Medium Priority
?
199 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 70

Accepted Solution

by:
Scott Pletcher earned 800 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

877 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