Tuesday, March 20, 2012

Changing a column name

How can you change a Column name for MS SQL 2000 ?
something like :
ALTER TABLE [dbo].[MyTable]
OldName RENAME NewName
GO
thank youFrom BOL,

--This example renames the contact title column in the customers table to title.

EXEC sp_rename 'customers.[contact title]', 'title', 'COLUMN'|||thanks a lot|||So why does EM do this?

EXECUTE sp_rename N'dbo.myTable00.AccID', N'Tmp_AccID_new', 'COLUMN'
GO
EXECUTE sp_rename N'dbo.myTable00.Tmp_AccID_new', N'AccID_new', 'COLUMN'
GO|||Mainly for backward compatibility, I would guess. SQL 7.0 might not have supported renaming columns.|||EM is really a strange application
SELECT CASE doesn't work for example|||EM is really a strange application
SELECT CASE doesn't work for example

You mean in the View window...

ALL of that stuff should be done in Query Analyzer.

I like to see what EM does when you change a table..they usually try to provide the best practices approach.

For example, go change the order of a column, or drop a column in EM, and then save the script...

Know what it does? It doesn't use ALTER, and there's a very good reasonm for that.

No comments:

Post a Comment