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 |
|
soori457
Yak Posting Veteran
85 Posts |
Posted - 2008-02-20 : 05:12:24
|
| In Emp Table I have some data, Now I want to create a new table Employee with same data.with this statement I got into.select * into Employee from Empwith out into statement, I want to create a tableIs it possibleSuresh Kumar |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-02-20 : 05:15:43
|
| Yes. Script out the Emp table, Make change to table name in script and execute script.Then use INSERT...SELECT statement to fill the data.In fact this is much preferred method than SELECT...INTOHarsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-20 : 05:35:07
|
quote: Originally posted by soori457 In Emp Table I have some data, Now I want to create a new table Employee with same data.with this statement I got into.select * into Employee from Empwith out into statement, I want to create a tableIs it possibleSuresh Kumar
As said, Generate script of EmpRename Emp to EmployeeRun the scriptThenInsert into EmployeeSelect * from EmpMadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-20 : 05:55:57
|
quote: Originally posted by soori457 In Emp Table I have some data, Now I want to create a new table Employee with same data.with this statement I got into.select * into Employee from Empwith out into statement, I want to create a tableIs it possibleSuresh Kumar
DO you mean you want to create table but should not populate it with data. then you can use same statement itself but like thisselect top 0 * into Employee from Emp |
 |
|
|
soori457
Yak Posting Veteran
85 Posts |
Posted - 2008-02-21 : 00:01:45
|
| How to Generate the Script of Emp TablePlease tell me.Thanks in AdvanceSuresh Kumar |
 |
|
|
SusanthaB
Starting Member
14 Posts |
Posted - 2008-02-21 : 00:13:37
|
| Which version of SQL Server are you using? If its 2000, you can use Enterprise Manager tool. If its 2005, you can use SQL Server Management Studio.Below steps are for SQL Server 2005. In Management Studio, 1. select the table from the object explorer.2. right click on the table.3. select "script table as".4. select "CREATE TO".Susantha BathigeSenior DBA, Sri Lanka |
 |
|
|
sunil
Constraint Violating Yak Guru
282 Posts |
Posted - 2008-02-21 : 00:17:41
|
| If you are using sql server 2005, then, right click on table for which you want to generate script.select "Script table as" option. Select Create To-->New Query Editor Window. It will generate script in query window. Rename table name to your desired table name "Employee". Run this script by pressing F5.Open new query window, and use Insert into EmployeeSelect * from EmpHope you will be able to do. |
 |
|
|
|
|
|
|
|