Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ischenk
Starting Member
15 Posts |
Posted - 2008-07-22 : 19:13:44
|
| Can someone tell me how to correct this code? I am trying to get this to trigger to print out a message when this table is updated. the error I'm getting is:Msg 156, Level 15, State 1, Procedure Up_Prod, Line 10Incorrect syntax near the keyword 'select'.Msg 156, Level 15, State 1, Procedure Up_Prod, Line 11Incorrect syntax near the keyword 'select'.The code I used was this:use Northwindgocreate trigger Up_Prodon dbo.Productsfor update asif update (UnitsInStock)begindeclare @string varchar(100)declare @PName varchar (20)declare @Units varchar (5)set @PName = select ProductName from insertedset @Units = select UnitsInStock from insertedset @string = @PName + '' + 'now has' + '' + @Units + 'units.'raiserror (@string, 10, 1)endI'm still new to triggers and most SQL code for that matter. Any help would be greatly appriciated. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
ischenk
Starting Member
15 Posts |
Posted - 2008-07-22 : 19:26:08
|
| Thanks, tkizer. I know that I shouldn't be doing it like this, but they wanted to see it in a trigger form. I am a moron. I should have done it just like you have it. However, I did find out that putting the select statement in Parenthesis also works. Thanks for your help. You really do know your stuff. |
 |
|
|
|
|
|
|
|