Jump to content

Search the Community

Showing results for tags 'sql sqlserver2008 trigger'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 1 result

  1. sql_learner

    INSERT trigger

    Hello, I am trying to create an insert trigger for the first time and have some difficulty getting the trigger below to work. I am using MS SQL Server 2008 R2 I want to create an INSERT trigger that will prevent the adding of a row with a province that is not BC. Essentially if the province is BC the trigger should allow the update to happen, if the province is not BC the trigger should prevent the row from being added. I know I need to use the inserted virtual table, but I am not sure what I am doing wrong. Any help would be very appreciated, thanks! // code to testinsert Employeesvalues (10, 'Brown', 'Joe', '21 Jump Street', 'Vancouver', 'BC', 'V6R 5Z4', '6045555555','1981-07-23') insert Employeesvalues (11, 'Brown', 'Joe', '21 Jump Street', 'Vancouver', 'ON', 'V6R 5Z4', '6045555555','1981-07-23') go //INSERT TriggerCREATE TRIGGER tr_insert_employeeON Employeesfor insertasif (select province from inserted) <> 'BC' BEGINPRINT 'record will not update if province is not BC'ROLLBACK TRANSACTION END
×
×
  • Create New...