Computed column renaming
jstangroome
Posts: 26
A portion of a script generated by SQL Compare 5.1 looks like this:
PRINT N'Altering [dbo].[doMaster]'
GO
sp_rename N'[dbo].[doMaster].[GLAccount]', N'GlAccount', 'COLUMN'
GO
@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
Unfortunately it is failing with this error message:
Altering [dbo].[doMaster]
Msg 4928, Level 16, State 1, Procedure sp_rename, Line 520
Cannot alter column 'GLAccount' because it is 'COMPUTED'.
Will I need to hand-edit this part of the script?
Thanks,
- Jason
PRINT N'Altering [dbo].[doMaster]'
GO
sp_rename N'[dbo].[doMaster].[GLAccount]', N'GlAccount', 'COLUMN'
GO
@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
Unfortunately it is failing with this error message:
Altering [dbo].[doMaster]
Msg 4928, Level 16, State 1, Procedure sp_rename, Line 520
Cannot alter column 'GLAccount' because it is 'COMPUTED'.
Will I need to hand-edit this part of the script?
Thanks,
- Jason
Comments
It may be helpful if you could tell us what SQL Compare is meant to be doing. Can you post up a bit more of the script? For instance, is this part of a table rebuild?
This is purely a difference of case on a single column on two tables that are otherwise identical. It is not part of a rebuild.
Thanks,
- Jason
It sounds like a new 'feature' added as part of the treat items as case sensitive option. It probably doesn't consider computed columns. I'll look more deeply into it tomorrow.
I've reproduced and confirmed this as a bug. Someone will begin looking into fixing this little problem for a future version of SQL Compare.
When you use the 'treat items as case-sensitive' option and a column name exists in two tables in the databases you're comparing and the column name differs only in case, SQL Compare will rather intelligently use sp_rename. This doesn't seem to work on computed columns, though, for the reason you have pointed out.
Thanks!
Thank you.