I am trying call to sp_rename
inside transaction (BEGIN TRANSACTION
), but it shows this error message:
Can't run sp_rename from within a transaction., Error 17260, Procedure sp_rename, Line 78
The sp_rename
code checks for any open transactions::
/*
** Running sp_rename inside a transaction would endanger the
** recoverability of the transaction/database. Disallow it.
** Do the @@trancount check before initializing any local variables,
** because "select" statement itself will start a transaction
** if chained mode is on.
*/
if @@trancount > 0
begin
/*
** 17260, "Can't run %1! from within a transaction."
*/
raiserror 17260, "sp_rename"
return (1)
end
else
begin
set chained off
end
I don't understand why these actions are a danger....
Additionally, I need a way to call this stored procedure within the transaction and then rollback this action.
Any suggestions?