March 14, 2012 at 7:56 am
----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'
Edit/Delete Message
March 14, 2012 at 8:00 am
sql renames tables via a stored procedure..the syntax you are using is appropriate for Oracle only, i think.
sp_rename 'OriginalTableName','NewTableName'
--or
-- if you have two items with the same name but different schemas,
--identify the schema specifically
sp_rename 'dbo.OriginalTableName','NewTableName'
sp_rename 'Orange.OriginalTableName','NewTableName'
--above renamed to Orange.NewTableName
--renaming a column
sp_rename 'dbo.OriginalTableName.Entitynm','EntityName','column'
johnny1walker (3/14/2012)
----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'
Edit/Delete Message
Lowell
March 14, 2012 at 8:21 am
thank you very much.
renaming table name success
but
--i dont renaming a column
Use test
GO
sp_rename 'tablo4','d1','d11'
GO
just started to sql
Can you write code
thanks.
March 14, 2012 at 8:34 am
For renaming a column the syntax is:
EXEC sp_rename 'Table.OldColumnName', 'NewColumnName', 'COLUMN'
Andy
==========================================================================================================================
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy