Smart Rename should be smarter about changing schema &table name
When renaming both the table and schema name, and a table already exists w/ the old table name but new schema name, Smart Rename errors because it does not detect this conflict and tries to first rename the table to the conflicting table name.
e.g., renaming stage.dboTable1 to dbo_stage.Table1 (and stage.Table1 already exists):
EXEC sp_rename N'[stage].[dboTable1]', N'Table1', N'OBJECT'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER SCHEMA [dbo_stage] TRANSFER [stage].[Table1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
would work if script instead did this:
ALTER SCHEMA [dbo_stage] TRANSFER [stage].[dboTable1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
EXEC sp_rename N'[dbo_stage].[dboTable1]', N'Table1', N'OBJECT'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
Note: your editor control apparently interprets special characters as HTML
1
vote
Rick Thorington
shared this idea