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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to copy one table to another

Author  Topic 

rudba
Constraint Violating Yak Guru

415 Posts

Posted - 2009-01-28 : 13:49:38
How to copy data one table to another database table.
The table structurs are same, just database name is different.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-28 : 13:53:14
Use Export/Import Wizard.
or


Insert into DB2.table
Select * from DB1.table
Go to Top of Page

rudba
Constraint Violating Yak Guru

415 Posts

Posted - 2009-01-28 : 13:56:07
thanks sodeep
Go to Top of Page

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-01-28 : 23:07:12
another way-------
If u want same columns in new table also, then

select * into db1..Newtable from db2..table
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2009-01-29 : 02:51:56
I'm being picky here but sodeeps script needs a slight modification:

Insert into DB2.dbo.table
Select * from DB1.dbo.table


- Lumbago
Go to Top of Page

rudba
Constraint Violating Yak Guru

415 Posts

Posted - 2009-01-29 : 10:51:56
Thanks guys
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-29 : 11:36:55
you can also use OPENROWSET if its for adhoc transfer

http://msdn.microsoft.com/en-us/library/ms190312.aspx


Go to Top of Page
   

- Advertisement -