Reputation: 11
I need to execute these t-sql statements using c#, for some reasons I do not want to put them in stored procedure.
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
UPDATE mytable
SET col=col
WAITFOR DELAY '00:02:00'
ROLLBACK TRANSACTION
Upvotes: 0
Views: 154
Reputation: 1064324
You cannot execute that as one batch because it is not one batch. You cannot put GO in the middle - that separates batches in editors like SSMS but is not actually T-SQL itself.
Your code, however, does not need that GO - so just remove it. Or execute it as two separate batches on the same connection (which is exactly what tools like SSMS will do with this).
Upvotes: 3