My Test table has two columns:
id int not null
somecolumn varchar(10))
Now see my query:
USE TRY
BEGIN TRANSACTION T1
INSERT INTO Test VALUES(7,'hi');
GO
INSERT INTO Test VALUES(8,'hi','ABC');
GO
PRINT @@ERROR
if @@ERROR>0
ROLLBACK TRANSACTION T1
ELSE
COMMIT TRANSACTION T1
I know that my second query is wrong so I want transaction to rollback but it inserts the first query then shows this message:
(1 row(s) affected)
Msg 213, Level 16, State 1, Line 1
Column name or number of supplied values does not match table definition.
213