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.
| Author |
Topic |
|
loveoracle
Starting Member
2 Posts |
Posted - 2005-11-29 : 06:38:51
|
| Hi,I am new in sql server.I want to rename the table.I use following commnad;select * into e2 from e1But some of the constraints are not transfered.Is there any command like oracle?Pleas tell me the solution.Thanks,Prathamesh. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2005-11-29 : 06:53:04
|
| [code]select * into e2 from e1[/code]creates another table e2 with same structure as e1 and also insert records into e2 from e1. It does not create any constraints in e2.Use Enterprise Manager to create the scripts for e1 and change the table name and run in Query Analyser-----------------[KH] |
 |
|
|
Hariarul
Posting Yak Master
160 Posts |
Posted - 2005-11-29 : 06:54:46
|
| Hi Prathamesh,There are two ways mentioned below to rename a table.GUI :Just right click the table in EM and rename it. Code :This example renames the customers table to custs.EXEC sp_rename 'customers', 'custs'regards,Hari Haran Arulmozhi |
 |
|
|
loveoracle
Starting Member
2 Posts |
Posted - 2005-11-29 : 07:52:02
|
Thanksquote: Originally posted by Hariarul Hi Prathamesh,There are two ways mentioned below to rename a table.GUI :Just right click the table in EM and rename it. Code :This example renames the customers table to custs.EXEC sp_rename 'customers', 'custs'regards,Hari Haran Arulmozhi
|
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-29 : 08:07:36
|
| Generate SQL Script for that table and change the table name run itThen copy dataInsert into e2(columns) select columns from e1If you dont want to have e1 table then look for sp_rename in Books On Line, SQL Server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
srinivas.alwala
Starting Member
30 Posts |
Posted - 2011-05-30 : 08:34:17
|
| Dear Madhavan,Kindly let me kknow,what happens when we rename the table, if there are indexes created on it, if there is primary/foreign key relationship with other tables... any other disadvantages.. |
 |
|
|
|
|
|
|
|