how to rename table in sqlserver 2005

Posted by Venky.Net under Sql Server on 5/1/2012 | Points: 10 | Views : 3989 | Status : [Member] | Replies : 11
hi
how to change name for database and table




Responses

Posted by: Gow.Net on: 5/1/2012 [Member] Starter | Points: 25

Up
0
Down
Database Name :
 sp_renameDB 'oldDB','newDB'

or
ALTER DATABASE Test MODIFY NAME = NewTest


Tablename:

 sp_rename 'tablename.oldcolumnname','new columnName','Column' 



gowthaman8870226416

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 5/19/2012 [Member] Starter | Points: 25

Up
0
Down

To Rename Database:

exec sp_renamedb 'Test1','Sample'

To Rename Table:


sriram

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gemamgall on: 6/27/2012 [Member] Starter | Points: 25

Up
0
Down
in sql server management studio right click on tablename and use rename option to change table name

Thanks and Regards,

Vinay Gandhi
www.quadtechindia.com

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Johnbhatt on: 6/28/2012 [Member] Starter | Points: 25

Up
0
Down
For doing Codes, above Answer Contains code. In visual way, Log In to SQL Server Management Studio as Server Admin (sa Login). Then Just Visually as you rename Files in Explorer, Right Click and Choose Rename from Options. Same for Tables also.

John Bhatt
Glad to Know, Free to Share.....
http://www.johnbhatt.com

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bhupentiwari on: 6/28/2012 [Member] Starter | Points: 25

Up
0
Down
Open sql server management studio
click on database
select your databse
select your table which you want rename
right click on table and give new name

Thanks n Regards
Bhupendra Tiwari

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saranya Boopathi on: 6/29/2012 [Member] Starter | Points: 25

Up
0
Down
Renaming database table to new name.
We can change the table name to another name.
[code]
sp_RENAME 'Tablename_old', 'Tablename_New'
[/code]



Saranya Boopathi

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 6/29/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi,

Refer this url

http://www.java2s.com/Code/PostgreSQL/Table/Renametheemployeestabletopersonnel.htm

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/29/2012 [Member] Silver | Points: 25
Posted by: CGN007 on: 6/29/2012 [Member] Silver | Points: 25

Up
0
Down
Yes by using sp_rename:

EXEC sp_rename 'Stu_Table', 'Stu_Table_10'

More details on MSDN.


Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/29/2012 [Member] Silver | Points: 25
Posted by: CGN007 on: 6/29/2012 [Member] Silver | Points: 25

Up
0
Down
Mark as Answer if its helpful to you,that motivates...

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response