Showing posts with label db1. Show all posts
Showing posts with label db1. Show all posts

Monday, March 19, 2012

Inter-Database References

Hello

Suppose a database Db1 with tables tl1 and tl2 and a second database db2
with tables tl3 et tl4.

Is it possible to make a join between tables of the two databases ?

As for example, Select * from tl1 INNER JOIN tl3 where tl1.Field1 =
tl3.Field3

Thank for any help

ThierryIf we have the databases Db1 and Db2 on the same server
we can join as follows

Select *
from db1..tl1 a
INNER JOIN db2..tl3 b on a.Field1 = b.Field3

HTH
Srinivas Sampangi

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Monday, March 12, 2012

Interaction between tables of local and remote SQL databases

Hi all,

I would be very glad if someone can suggest me what techniques I should use in the following scenario:

I have 2 SQL Server databases : DB1 and DB2. DB 1 is on a remote server (hosting server) and DB 2 is on a local server.

Some tables of each db contain tables that are polulated and changed by the appropriate application, i.e.:

DB1.users, DB1.orders,... etc are managed by "webapplication"

DB1.products ... are not managed by "webapplication" : in fact only used to read from

DB2.products, DB2.customers, .... etc are managed by "winapplication"

DB2.orders,....are partially managed by "winapplication"

Since the amount of data can go over 100000 records i'm wondering what would by the best approach to :

- synchronize the data of DB1.products and DB2.products in DB1 on remote server (updated newly added rows and update changed rows,....)

- the products data is only (at the moment) added, edited and deleted on the local server

I think SQLBulkCopy will not do the job. Should it be possible with some query? Or...?

Any suggestions are appreciated!!

O.

Some addition:

- Does SQLBulkCopy copy-append data to the destination database.table?

- What about identity keys?

- Should it be the best solution to modify the SqlCommand so it takes only those rows I want to be inserted as (depending on bulkcopies already done before) or is this done by SQLBulkcopy itself....?

Please inform.

O.

Friday, March 9, 2012

Inter Database Security

I have a stored procedure db1.dbo.sp1
this Stored Procedure grabs data from another database. Say db2.dbo.tbl1

If i call the qry1.
how does the security from db2 come in to play? if at all?

For example, If I am SQL Server Authenticated, for DB1 but not for DB2 will the SP fail. etc.If you have security to db1 but not db2, and you run it as yourself, it will fail.

HTH|||Tnx for the info. I picked up some additional tips and was able to confirm your suggestion on our sql servers over here.

Is there anyway to use NT Authentication in the first db. Then from within a stored procedure (in the 1st database), access the 2nd database using the sa account?

I.E. pass a sa login request to the 2nd database.