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
 Development Tools
 ASP.NET
 Importing data from table of another database

Author  Topic 

Swati Jain
Posting Yak Master

139 Posts

Posted - 2008-01-08 : 06:50:52
Hi,I have taken backup of database . and creatd the similar database.
Now i have clean the new databse.
I want to import the data from tables of first database(database before backup) to to tables of new database(Backup database)
I dont want to write the insert statement for every table for inserting data from same table of original database.
Is there any quick workaround for this?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-08 : 07:42:13
Restore the database

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Swati Jain
Posting Yak Master

139 Posts

Posted - 2008-01-08 : 08:39:07
quote:
Originally posted by madhivanan

Restore the database

Madhivanan

Failing to plan is Planning to fail



Hi Madhivanan,

Actualy I want to not restore whole database,But I want to get data from some tables
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-08 : 08:45:26

Use this method

Insert into newdb.dbo.table(columns)
select columns from olddb.dbo.table


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Swati Jain
Posting Yak Master

139 Posts

Posted - 2008-01-08 : 09:37:04
quote:
Originally posted by madhivanan


Use this method

Insert into newdb.dbo.table(columns)
select columns from olddb.dbo.table


Madhivanan

Failing to plan is Planning to fail



Is there no other method to do this . bcoz i hv n number of tables having n number of columns . so doing this thing everytime is realy cumbersome
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-09 : 03:13:10
Run this


select 'insert into newdb.dbo.'+name +' select * from olddb.dbo.'+name from sysobjects
where xtype='u'

Copy the result back to QA and run one by one

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -