December 11, 2003 at 1:19 pm
Hi,
As far as i can see, there is no way to ALTER the "name" of a table column thru TSQL, though it seems that you can do everything else with a column thru the TSQL "ALTER" statement.
Is there a logical reason for this?Do I have to go to EM and manually change the name of the column that I want to alter?
Cheers,
yogiberr
December 11, 2003 at 1:34 pm
sp_rename
December 11, 2003 at 2:04 pm
sp_rename uses utilizes DBCC RENAMECOLUMN. As this command is undocumented, I guess there is no direct way with T-SQL.
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 11, 2003 at 2:50 pm
thanks folks,
So, would I be best to:
1) use "sp_depends" on the table that I am about to alter (to find out which other db objects the column name-change could affect)
2) use "sp_rename" to rename the table column.
3) update all the objects that reference the renamed column.
Did i understand correctly?
ta,
yogiberr
December 12, 2003 at 1:36 am
Hi
What I usually do if I'm not sure how to do something in QA is to do what I want to do in EM in a test database and record it all through profiler. You can then pick out the QA commands required.
December 12, 2003 at 3:14 am
Good tip.
thanks all.
yogi
December 12, 2003 at 8:44 am
I go into EM, make all the changes, choose "Save change script" to capture all the commands, then exit without saving the actual changes.
Or sometimes I do save the actual changes, but archive the "change script" so I have a history of what was done.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply