Professional Web Applications Themes

Email Validation Trigger - Microsoft SQL / MS SQL Server

Hiya Friends! I am currently not at a pc with sql server 2000 so this may seem like a silly question but will the trigger below work? I am trying to create a validation Trigger that is attached to the 'Email' field in the table 'tblPatients', which will raise an error if a user enters an inappropriate email address. CREATE TRIGGER uTR_ValEMail ON tblPatients AFTER INSERT AS BEGIN IF CONTAINS(EMail, '') COMMIT TRANS ELSE RAISERROR('Inappropriate Email entered', 16, 1) ROLLBACK TRANSACTION END GO Should I use a constraint rather than a Trigger for this purpose and would the constraint be ...

  1. #1

    Default Email Validation Trigger

    Hiya Friends!

    I am currently not at a pc with sql server 2000 so this
    may seem like a silly question but will the trigger below
    work? I am trying to create a validation Trigger that is
    attached to the 'Email' field in the table 'tblPatients',
    which will raise an error if a user enters an
    inappropriate email address.

    CREATE TRIGGER uTR_ValEMail ON tblPatients
    AFTER INSERT
    AS
    BEGIN
    IF CONTAINS(EMail, '')
    COMMIT TRANS
    ELSE
    RAISERROR('Inappropriate Email entered', 16, 1)
    ROLLBACK TRANSACTION
    END
    GO

    Should I use a constraint rather than a Trigger for this
    purpose and would the constraint be CONTAINS(EMail, '')?

    Thanks all.

    Kagsy

    Kagsy Guest

  2. #2

    Default Re: Email Validation Trigger

    If not sure whether the CONTAINS clause can be used in a constraint, but for
    your case, a simple check as whether the email field has the '' symbol can
    be solved by a constraint. You do not need a trigger for that, unless you
    want to write more complex logic. Here is a sample:
    ======
    CREATE TABLE samp_test
    (
    colA VARCHAR(100) CHECK (CHARINDEX('', colA) > 0)
    )
    ======
    --
    HTH,
    SriSamp
    Please reply to the whole group only!
    http://www32.brinkster.com/srisamp

    "Kagsy" <co.uk> wrote in message
    news:077201c35d96$46e24f60$gbl... 


    SriSamp Guest

  3. #3

    Default Re: Email Validation Trigger

    Dave,

    Its easy to be critical and not so to give constructive comments. What value
    did your comments add to Kagsy's original question. None! the objective of
    the Newsgroups is to offer help and support to those that need help and not
    to belittle their efforts!

    Karen

    "Dave" <co.uk> wrote in message
    news:u$phx.gbl... 
    > for 
    > can [/ref]
    you 
    > >
    > >[/ref]
    >
    >[/ref]


    Karen Guest

Similar Threads

  1. Trigger flash movie to play from an email?
    By Judy in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: October 25th, 10:24 AM
  2. Email Validation
    By sandramcewen in forum Macromedia Flex General Discussion
    Replies: 11
    Last Post: August 19th, 03:46 PM
  3. sending an email from a table trigger (before inserting row)
    By Holger Baer in forum Oracle Server
    Replies: 10
    Last Post: July 7th, 02:37 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