copy data from two database | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

copy data from two database

hi all,
I have one database qlns and qlnsluu, each database have one table hoso with the same definition. Now I want to insert some record from hoso of qlns to hoso of qlnsluu. could any one tell me the sql statement.
thanks.
1 Use DTS
2 Use query Insert into hoso.dbo.qlnsluu(columns)
Select columns from hoso.dbo.qlns Madhivanan Failing to plan is Planning to fail
Madhivanan, I think you swapped the database names and table names in that query:<br /><br />INSERT INTO qlnsluu.dbo.hoso (&lt;columns&gt<img src=’/community/emoticons/emotion-5.gif’ alt=’;)‘ /><br />SELECT &lt;columns&gt; FROM qlns.dbo.hoso
Link server is a antoher possibility. but Query is the best way —————————————-
http://dineshasanka.blogspot.com/

quote:Originally posted by dineshasanka Link server is a antoher possibility. but Query is the best way —————————————-
http://dineshasanka.blogspot.com/
Linked Server is necessary only if the db resides in other Server. Otherwise no need for Linked Server Adriaan, Questioner says
Now I want to insert some record from hoso of qlns to hoso of qlnsluu.
So copying is from hoso of qlns to hoso of qlnsluu. So the target is hoso of qlnsluu
Am I missing anything? Madhivanan Failing to plan is Planning to fail
Madhivanan, your query copies data from table dbo.qlns to table dbo.qlnsluu in the same database, hoso. The question was about two different databases, qlns and qlnsluu, which both have a table dbo.hoso, and how to copy data from one database to the other.
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by Adriaan</i><br /><br />Madhivanan, your query copies data from table <b>dbo.qlns</b> to table <b>dbo.qlnsluu</b> in the same database, <b>hoso</b>.<br /><br />The question was about two different databases, <b>qlns</b> and <b>qlnsluu</b>, which both have a table <b>dbo.hoso</b>, and how to copy data from one database to the other.<br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br />Thanks. I forget to check the Database Name [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail
]]>