Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Way to re-name existing column in a table using T-SQL??

Status
Not open for further replies.

sobeit

Programmer
Sep 11, 2000
38
US
I need to re-name field names in an existing table, and
I can't drop the table b\c it has records in it.
ALTER COLUMN does not include any syntax for re-naming
a field name.


Thanks in advance.
 
EXECUTE sp_rename N'dbo.mytable.oldname', N'newname', 'COLUMN'

obviously if there are indexes tied to the column you will have additional problems

you could also just do this though enterprise manager which is a lot easier
 
Thanks....couldn't use the Enterprise manager b\c
i need have it in a script.
I couldn't find any system SP where you can also change
the default value of a column.

If there's one, then please HELP.
Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top