Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 alter table name error

Author  Topic 

johnny1walker
Starting Member

17 Posts

Posted - 2012-03-14 : 09:40:49

----change In the name of Table 5 Table 6
Use test
GO
ALTER TABLE NAME tablo5 RENAME TO tablo6;
GO

but error messages::
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'tablo5'.
------------------
------------------
----tablo4 d1 ==> d11 change.
Use test
GO
ALTER TABLE tablo4 RENAME COLUMN d1 TO d11;
GO
error messages::

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'RENAME'

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-03-14 : 10:12:55
Is that MS SQL Server?
I would use sp_rename...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

johnny1walker
Starting Member

17 Posts

Posted - 2012-03-14 : 12:13:12
yes mssql
thanks.i use sp_rename
but i dont rename column
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-14 : 12:50:23
quote:
Originally posted by johnny1walker

yes mssql
thanks.i use sp_rename
but i dont rename column


you can use sp_rename to rename column also

it will be like

EXEC sp_rename 'Tablename.currentcolumnname', 'Newcolumnname', 'COLUMN';


In any case please make sure you do an impact analysis to see dependent objects before you apply the change so that you can reflect changes in all the required places

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -