Tuesday, June 23, 2015

Renaming a stored procedure is just one more thing you may do with sp_rename in T-SQL!

If your sproc is named "Whatever" then...

IF OBJECT_ID(N'Whatever') IS NOT NULL
   BEGIN
      PRINT 'We are renaming Whatever.'
      EXEC sp_rename 'Whatever', 'SomethingElse'
   END
ELSE
   BEGIN
      PRINT 'Whatever does not exist and will not be renamed.'
   END
GO

No comments:

Post a Comment