Solved

notify sql_users when certain user insert adata in atable

Posted on 2002-06-11
3
174 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:
ScottPletcher 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
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
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now