> yep, the only way you can do this in SQL Server is to use > that SP (assuming > you can fire a system sp).
Looking at the contents of sp_rename, all its basically doing is looking up the sysid for that object and renaming it in the systables. this *could* be done from a custom query, I guess, if you could be bothered and wanted to re-invent the wheel. for columns, sp_rename is actually using the undocumented DBCC RENAMECOLUMN function. > -----Original Message----- > From: Robertson-Ravo, Neil (RX) > [mailto:[EMAIL PROTECTED] > Sent: 27 June 2003 10:03 > To: '[EMAIL PROTECTED]' > Subject: RE: [ cf-dev ] SQL: rename a column > > > yep, the only way you can do this in SQL Server is to use > that SP (assuming > you can fire a system sp). You cannot alter a column name in > SQL Server > using 'Alter Table' the way you can in other DB models. > > N > > -----Original Message----- > From: Rich Wild [mailto:[EMAIL PROTECTED] > Sent: 27 June 2003 09:56 > To: '[EMAIL PROTECTED]' > Subject: [ cf-dev ] SQL: rename a column > > > Hiya gals n guys! > > Could anyone give me the T-SQL I need to rename a column? > > I need to do it programmatically - basically given column > name x and a new > column name y, I need to rename x to y without losing any of > the data that > exists in column x. > > I can't seem to find anything in sqlbol apart from dropping x and then > adding y, but I need to keep the data, so this would require > moving all that > column's data to a temptable, dropping x, adding y, and then > re-inserting > data into y - which sounds like a kerazee and long winded > process to me, and > the cpu would prob thank me for avoiding doing it this way. > > ------------------------------------------------------- > Rich Wild > Senior Web Developer > > ------------------------------------------------------- > e-mango Tel: 01202 755 300 > Gild House Fax: 01202 755 301 > 74 Norwich Avenue West > Bournemouth Mailto:[EMAIL PROTECTED] > BH2 6AW, UK http://www.e-mango.com > ------------------------------------------------------- > This message may contain information which is legally > privileged and/or confidential. If you are not the > intended recipient, you are hereby notified that any > unauthorised disclosure, copying, distribution or use > of this information is strictly prohibited. Such > notification notwithstanding, any comments, opinions, > information or conclusions expressed in this message > are those of the originator, not of e-mango.com ltd, > unless otherwise explicitly and independently indicated > by an authorised representative of e-mango.com ltd. > ------------------------------------------------------- > > > -- > ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > For human help, e-mail: [EMAIL PROTECTED] > > -- > ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > For human help, e-mail: [EMAIL PROTECTED] > -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
