Group:  Microsoft Access ยป microsoft.public.access.adp.sqlserver
Thread: Rename a column using SQL

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Rename a column using SQL
JornyO 04.07.2006 18:53:01
I am trying to rename a colum using an SQL statement run in a macro using the
RunSQL action. Some forums have told me to use the following:

ALTER TABLE [CurrentTable] RENAME COLUMN [OldName] TO [NewName];

When I try to run this I get the following message: "Syntax Error in the
ALTER TABLE statement". What am I doing wrong? It seems pretty simple to
me, and many other forums have offered this advice for doing this.
Re: Rename a column using SQL
"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)> 04.07.2006 20:52:47
Maybe I'm wrong but I'm not sure if SQL-Server offerts support for the ALTER
TABLE RENAME COLUMN statement. Instead, you should use the stored procedure
sp_rename:

sp_rename 'CurrentTable.OldName', 'NewName', 'COLUMN'

For the RunSQL command, I don't know what would be the exact syntax and it's
also possible that you will have to add the EXEC command at the beginning:

Exec sp_rename 'CurrentTable.OldName', 'NewName', 'COLUMN'

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


"JornyO" <JornyO[ at ]discussions.microsoft.com> wrote in message
news:04C5054F-5A48-492C-87F9-A36C0AD666B2[ at ]microsoft.com...
[Quoted Text]
>I am trying to rename a colum using an SQL statement run in a macro using
>the
> RunSQL action. Some forums have told me to use the following:
>
> ALTER TABLE [CurrentTable] RENAME COLUMN [OldName] TO [NewName];
>
> When I try to run this I get the following message: "Syntax Error in the
> ALTER TABLE statement". What am I doing wrong? It seems pretty simple to
> me, and many other forums have offered this advice for doing this.


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net