View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 07:12 PM
Dan Guzman
 
Posts: n/a
Default Re: Querying tables from different databases

You can use 3-part names to qualify the object references:

INSERT INTO MyDatabase1.dbo.MyTable1
SELECT *
FROM MyDatabase2.dbo.MyTable2

--
Hope this helps.

Dan Guzman
SQL Server MVP

-----------------------
SQL FAQ links (courtesy Neil Pike):

http://www.ntfaq.com/Articles/Index....partmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------

"Henri" <lemartin@nospam.inv> wrote in message
news:3f8065cb$0$27019$626a54ce@news.free.fr...
> Hello,
>
> I am quite new to ms-sql and I have a problem : I want to create an

SQL
> request which would copy serveral records from a table in a given

database
> to another table (with exactly the same structure) in another database
> (theses two tables and databases already exist).
>
> Could you please tell me how to do this ? I dont know how to access

two
> different databases in a single SQL request.
>
> Thank you for you help.
>
>
>



Reply With Quote