I'm in query analyzer and I have 2 databases on this same server that I want
to reference in a query. How do I go about doing that? In other words, I
want to create an insert query which takes records from one database and
inserts them into a table in another database.
Thanks,
BrianAssuming that you have appropriate rights in both databases, use three
part naming:
INSERT INTO db1.owner.tablename (Column)
SELECT COLUMN
FROM db2.owner.tablename
HTH,
Stu|||Thanks - I thought I tried that, but I didn't include the 'owner'
"Stu" <stuart.ainsworth@.gmail.com> wrote in message
news:1145403151.928575.228920@.i39g2000cwa.googlegroups.com...
> Assuming that you have appropriate rights in both databases, use three
> part naming:
> INSERT INTO db1.owner.tablename (Column)
> SELECT COLUMN
> FROM db2.owner.tablename
> HTH,
> Stu
>|||Do you have access to both databases?
In SQL each object has a four part identifier which enables cross-database
and cross-server access, provided that the user privileges also allow it.
More information under "Using Identifiers as Object Names" in Books Online.
ML
http://milambda.blogspot.com/|||Here:
http://msdn2.microsoft.com/en-us/library/ms187879.aspx
ML
http://milambda.blogspot.com/