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)
 one database table data to other database table?

Author  Topic 

getur.srikanth@gmail.com
Yak Posting Veteran

77 Posts

Posted - 2008-01-30 : 11:19:13
I have to move data from one table (it is in different database) to my local database.

the data available in the table [dbo].[EmailNotification] from SKINID database move data to [dbo].[EmailNotification] SKINID_DEV database

Thanks in advance

singularity
Posting Yak Master

153 Posts

Posted - 2008-01-30 : 11:43:20
insert into SKINID_DEV.dbo.EmailNotification
select *
from SKINID.dbo.EmailNotification
Go to Top of Page

jdaman
Constraint Violating Yak Guru

354 Posts

Posted - 2008-01-30 : 11:43:48
If the databases are on the same server:
SELECT * INTO SKINID_DEV.dbo.EmailNotification FROM SKINID.dbo.EmailNotification

If the databases are on different servers you will need to search bol for "Linked Server". Once you have the 2 servers linked a variation of the above script should work.
Go to Top of Page

getur.srikanth@gmail.com
Yak Posting Veteran

77 Posts

Posted - 2008-01-30 : 12:05:21
In my case SKINID.dbo.EmailNotification columns not equal to SKINID_DEV.dbo.EmailNotification.

Because I added some new columns in SKINID_DEV.dbo.EmailNotification (my local database table). I am getting error "Insert Error: Column name or number of supplied values does not match table definition."

Now I need only that columns data that exists in both table.


Go to Top of Page

jdaman
Constraint Violating Yak Guru

354 Posts

Posted - 2008-01-30 : 12:30:53
quote:
Originally posted by getur.srikanth@gmail.com

In my case SKINID.dbo.EmailNotification columns not equal to SKINID_DEV.dbo.EmailNotification.

Because I added some new columns in SKINID_DEV.dbo.EmailNotification (my local database table). I am getting error "Insert Error: Column name or number of supplied values does not match table definition."

Now I need only that columns data that exists in both table.




Looks like your on your way.

INSERT SKINID_DEV.dbo.EmailNotification ( column1, column2 )
SELECT column1, column2
FROM SKINID.dbo.EmailNotification
Go to Top of Page
   

- Advertisement -