View Full Version : SQL Server - Table Column Name Change
doog
February 22nd, 2005, 08:03 PM
Is there a way to change a table column name in SQL server using SQL not the enterprise manager?
degsy
February 22nd, 2005, 09:47 PM
Try this SQL code
ALTER TABLE `tablename` RENAME `newname` ;
doog
February 22nd, 2005, 10:35 PM
Is there a way to change the column name, not the table name?
degsy
February 22nd, 2005, 10:44 PM
you mean you want to change the field name?
You will have to work with the current info, but it should be something like
ALTER TABLE `tablename` CHANGE `fieldname` `newfieldname` INT( 25 ) NOT NULL AUTO_INCREMENT
Where
INT( 25 ) NOT NULL AUTO_INCREMENT
are the attributes of the filed.
doog
February 24th, 2005, 04:56 PM
Tried: ALTER TABLE MFN_EQ_RET_Combined_2_1_2005 CHANGE[service type] [service type_superseded] VARCHAR( 100 )
And this does not work. CHANGE is not a reserve work in SQL SERVER... Any other guesses?
degsy
February 24th, 2005, 05:00 PM
sorry, they are the commands I use with mySQL database.
Thought they may work with SQL Server aswell.
doog
February 24th, 2005, 09:40 PM
Thanks- I'm also a mySQL programmer and perfer it to
z1p
March 3rd, 2005, 09:50 PM
doog, don't know if you are still looking, but here is the online reference for sqlserver SQL. (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_aa-az_3ied.asp)
It looks like you are out of luck. Your only choice may be to add a new column, move the values over and delete the old column. Not pretty, but would serve the purpose.