I was executing below section of code on sqlserver
SET NOCOUNT ON
BEGIN TRY
BEGIN TRAN
select count(*) from my_table
delete from my_table where key = 1
COMMIT
PRINT 'Success!'
END TRY
BEGIN CATCH
ROLLBACK
PRINT 'Fail'+ ERROR_MESSAGE()
END CATCH
SET NOCOUNT OFF
Here my code is able to show the count of Select query but not able to show the result of delete query in result window.
Requirement:
To show the result of delete in query window.
Solution :
Remove SET NOCOUNT ON and SET NOCOUNT OFF from your block, you will be able to see the delete result.
SET NOCOUNT ON
BEGIN TRY
BEGIN TRAN
select count(*) from my_table
delete from my_table where key = 1
COMMIT
PRINT 'Success!'
END TRY
BEGIN CATCH
ROLLBACK
PRINT 'Fail'+ ERROR_MESSAGE()
END CATCH
SET NOCOUNT OFF
Here my code is able to show the count of Select query but not able to show the result of delete query in result window.
Requirement:
To show the result of delete in query window.
Solution :
Remove SET NOCOUNT ON and SET NOCOUNT OFF from your block, you will be able to see the delete result.
No comments:
Post a Comment