Solved

notify sql_users when certain user insert adata in atable

Posted on 2002-06-11
3
175 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server encoding for storing Indian languages 9 37
grouping logic 6 49
SQL Server - SQL field is defined as text 3 30
How to use Full Text CONTAINS with Case in SQL 6 20
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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
Viewers will learn how the fundamental information of how to create a table.

895 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

16 Experts available now in Live!

Get 1:1 Help Now