|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Help with CREATE TRIGGER syntaxAny help would be appreciated. What's wrong with the following syntax?
CREATE TRIGGER tr_CMR_Client_Status_Confirm ON [CMR Client Numbers] FOR INSERT, UPDATE AS IF UPDATE [Current Status] CASE WHEN [Current Status] = 'X' THEN [Status Flag] = [CMR Client Number ID] ELSE [Status Flag] = NULL END 1. IF UPDATE should have parentheses around the column name - note: if
any row's [Current Status] is updated, this will evaluate to true. 2. not a syntax error, but for clarity, should put a BEGIN..END after the IF 3. [biggest problem] There's no DML statement to do anything, just a CASE expression... 4. ... which is incorrectly written Look up UPDATE, CREATE TRIGGER and CASE in BOL It is quite unclear from the code given what table the [Status Flag] column belongs to, otherwise I could give an example of possible correct trigger code. Please provide DDL of the table. mike wrote: Show quote >Any help would be appreciated. What's wrong with the following syntax? > > >CREATE TRIGGER tr_CMR_Client_Status_Confirm >ON [CMR Client Numbers] >FOR INSERT, UPDATE > AS > IF UPDATE [Current Status] > CASE WHEN [Current Status] = 'X' THEN [Status Flag] = [CMR >Client Number ID] ELSE [Status Flag] = NULL END > > > > > > >
Other interesting topics
|
|||||||||||||||||||||||