Professional Web Applications Themes

Grabbing value for a trigger - Microsoft SQL / MS SQL Server

Hi group, I just created my first trigger, and I feel proud... It's a simple one: CREATE TRIGGER TriggerName ON Users FOR DELETE AS EXEC master..xp_sendmail 'Recipient Name', 'User deleted from such-and-such system.' GO I'd love it if I could have the e-mail say: 'User ' + The value of a particular column from the row that was deleted ' was deleted from such-and-such system.' From reading the BOL, it seems that I'll need to find an alternative method of doing what I want to do, going by this quote from BOL: A trigger is designed to check or change ...

  1. #1

    Default Grabbing value for a trigger

    Hi group,

    I just created my first trigger, and I feel proud... It's a simple one:

    CREATE TRIGGER TriggerName ON Users FOR DELETE AS
    EXEC master..xp_sendmail 'Recipient Name', 'User deleted from
    such-and-such system.'
    GO

    I'd love it if I could have the e-mail say:
    'User ' + The value of a particular column from the row that was deleted '
    was deleted from such-and-such system.'

    From reading the BOL, it seems that I'll need to find an alternative method
    of doing what I want to do, going by this quote from BOL:
    A trigger is designed to check or change data based on a data modification
    statement; ___it should not return data to the user___.

    But, I figured I'd post anyway.

    Thank you,

    Ray at work




    Ray Guest

  2. #2

    Default Re: Grabbing value for a trigger

    Hi Ray,

    DELETED.ColumnName will give you the value from the column of the row that
    was deleted. So if you did something like this you will get what you want:

    Master..XP_SENDMAIL 'Recipient Name', 'User:' + DELETED.UserName + ' has
    been deleted from the database'

    Also, I think what BOL says about not returning data back to the user is
    ...... RETURN 0 or RETURN Deleted.UserID etc..

    Thanks,
    Ram Thiru

    --
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at
    http://www.microsoft.com/info/cpyright.htm

    "Ray at <%=sLocation%>" <forit> wrote in message
    news:%phx.gbl... 
    method 


    Ram Guest

  3. #3

    Default Re: Grabbing value for a trigger

    Hi Ram,

    Thank you. I got it working now. I'm thrilled about my first trigger. I
    think I'm going to print it and hang it up on my wall. :]

    Ray at work

    "Ram [MSFT]" <microsoft.com> wrote in message
    news:phx.gbl... 


    Ray Guest

Similar Threads

  1. grabbing the desktop
    By Word in forum Macromedia Director Lingo
    Replies: 6
    Last Post: December 23rd, 12:55 PM
  2. Grabbing All Cookies
    By Ken Cox [Microsoft MVP] in forum ASP.NET General
    Replies: 1
    Last Post: July 29th, 03:05 AM
  3. [PHP] Grabbing info from other Sites
    By Michael Geier in forum PHP Development
    Replies: 9
    Last Post: July 20th, 07:44 PM
  4. Grabbing Info with PHP and cookies
    By Andrew Conner in forum PHP Development
    Replies: 0
    Last Post: July 11th, 06:04 PM
  5. Grabbing PHP files
    By uws in forum PHP Development
    Replies: 7
    Last Post: July 5th, 03:10 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139