Why does this SQL work in VS but not in code?

Posted by acidzombie24 on Stack Overflow See other posts from Stack Overflow or by acidzombie24
Published on 2010-05-19T19:25:41Z Indexed on 2010/05/19 19:50 UTC
Read the original article Hit count: 156

Filed under:
|
|
|

The line cmd.ExecuteNonQuery();

cmd.CommandText

CREATE TRIGGER  subscription_trig_0  ON  subscription   
 AFTER INSERT  AS  
UPDATE user_data 
   SET msg_count = msg_count + 1 
  FROM user_data
  JOIN INSERTED ON user_data.id = INSERTED.recipient; 

The exception:

Incorrect syntax near the keyword 'TRIGGER'.

Then using VS 2010, connected to the very same file (a mdf file) i run the query above and i get a success message.

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about c#