Groups | Blog | Home
all groups > sql server (alternate) > october 2004 >

sql server (alternate) : Changing Column Name on a table


mokles
10/7/2004 6:29:23 PM
Hi All,
I am trying to change column name on an existing table. I am using SQL
Server 7.

As the table is quite big, it is taking quite long time to do it.
By the way I could change the column name only through the Enterprize
Manager.

Is it possible to change the column name using SQL script?
Why the change of column name will depend on the size of the table?

Thanks for your answer.

-Mokles

shehzad NO[at]SPAM internav.com
10/7/2004 8:52:55 PM
Hi Mokles

Have you tried to rename the field using sp_rename.

Enterprise manager does the job using same kind of scripts but its not
intelligent enough I have observed in various scenarios that sometimes
it accomplishes simple tasks using long approach.

I wonder if there are any indexes on the table ?

Regards
Shehzad


[quoted text, click to view]
Dan Guzman
10/8/2004 12:04:18 AM
You can change a column name using sp_rename.

EXEC sp_rename 'MyTable.OldColumnName', 'NewColumnName', 'COLUMN'

See the Books Online for more information.

--
Hope this helps.

Dan Guzman
SQL Server MVP

[quoted text, click to view]

mokles
10/8/2004 7:38:50 PM
Today I tried to do it with sp_Rename and it worked well and fast.

Previously I was using profiler to see what the Enterprize Manager was
doing. And really it was using complicated method to change the column name.

Thanks all for the help

-Mokles


[quoted text, click to view]

mokles
10/8/2004 7:40:34 PM
I could do it using Sp_Rename.
Enterprize Manager was using complicated method to do the simple task
Anyway thanks for the help

-Mokles

[quoted text, click to view]

AddThis Social Bookmark Button