Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
The smarter way to update row that just inserted?
Message
De
12/12/2000 15:08:53
 
 
À
12/12/2000 13:54:13
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00452399
Message ID:
00452463
Vues:
14
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform