Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The smarter way to update row that just inserted?
Message
From
12/12/2000 15:08:53
 
 
To
12/12/2000 13:54:13
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00452399
Message ID:
00452463
Views:
13
The idea is good, but I don't think it can be done because of SQLServer's implementation. The reason you are getting an error after UPDATE is because variables can only be used in the WHERE clause. Thus, you cannot send the table in a parameter as you're trying to do.
>CREATE PROCEDURE usp_updateUserID
>    @Tablename nvarchar(128),
>    @pKey  nvarchar(50)
>AS
>    UPDATE @Tablename  --Got a syntax error on this line!
>        SET UserID= SYSTEM_USER
>        FROM @TableName, Inserted
>        WHERE @pKey.ID = Inserted.ID  --This line I'm not sure about syntax??
Sylvain Demers
Previous
Reply
Map
View

Click here to load this message in the networking platform