Solved

notify sql_users when certain user insert adata in atable

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
string fuctions 4 26
VB.net and sql server 4 36
Tsql query 6 22
Insert query into temp tables using Coldfusion 3 22
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

803 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