Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am working on a database and need to copy some tables of my existing database to another. Please provide me with a solution (Queries - Not through wizard) on how to do the above.

P.S. - I am working on Firebird SQL

Awaiting replies...

Thanks,
Hamza
Posted

u can insert selected data/table/record to another database's table try the following sample:

insert into TargetDb.dbo.TargetTable(Col1,col2,...)
Select ColId,SomeCol1,SomeCol2...
From SourceTable
 
Share this answer
 
Comments
Hamza Daginawala 20-Sep-11 1:59am    
thanks a lot for the replY mate. Just one more question....do i need to specify the column names? or i can use jus SELECT * FROM..........
SQL
insert into TestDestination.dbo.Employee (Column1, Column2, ...)
select  (Column1, Column2, ...) from TestSource.dbo.Employee


This will create a new table in TestDestination database
SQL
select  (Column1, Column2, ...) into Employee  from TestSource.dbo.Employee
 
Share this answer
 
v2
Comments
Hamza Daginawala 20-Sep-11 1:59am    
thanks a lot for the replY mate. Just one more question....do i need to specify the column names? or i can use jus SELECT * FROM..........
sachin10d 23-Sep-11 8:44am    
select * from will work fine only if all the columns are to be inserted
if you do have any identity column then you will have to specify all the columns except the identity column as identity column will be auto filled.
sachin10d 23-Sep-11 8:46am    
if there is no identity column in destination table then select * from will work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900