Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Location
    Cergy
    Posts
    65

    Unanswered: sp to send a message to a user ?

    Do you know a stored procedure ( or a query) to send a message to a SQLServer user ?

    Something like NET SEND but with a spid user

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    USA
    Posts
    115
    Using Enterprise Manager you can do it.

    Enterprise Manager -> SQL Server Group -> Server -> Management -> Process Info -> Select ID & Go to Properties -> Send Message

    or

    use xp_cmdshell to run any command from command prompt.

    May I know why you want this..?
    Last edited by rajeshpatel; 09-23-06 at 10:08.
    Rajesh Patel

    Everybody says - mistake is the first step of success, but it's not true. The correction of the mistake is the first step of success.

  3. #3
    Join Date
    Jan 2006
    Location
    USA
    Posts
    115
    I have got little good solution... check the below code..

    Code:
    Declare @Hname varchar(25)
    Declare @Final_MSG varchar(500)
    
    Select @Hname = hostname from master..sysprocesses where nt_username = 'user name'
    
    SET @Final_MSG = 'net send ' +  @hname + 'Hi..!'
    
    EXEC master..xp_cmdshell @Final_MSG, no_output
    Now create stored procedure as you required...
    Rajesh Patel

    Everybody says - mistake is the first step of success, but it's not true. The correction of the mistake is the first step of success.

  4. #4
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    that works but it assumes a couple of things. the login making the database connection is going to have to have what some may consider an unacceptable database role to execute xp_cmdshell. secondly, some network admins disable net send. I think 2005 might have a new bell or whistle for this. If you are working with 2000, how about email? xp_smtpsendmail I think it is called. Google it.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  5. #5
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    XPSMTP is what it is called, and it works great. Here is the link:
    http://sqldev.net/xp/xpsmtp.htm
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •