Monday, March 19, 2012

Crate connection in T-SQL

Helo everybody

How to crate differente connection in the same script and apply this in a query. I use Query analyser. I can do that?

If you ave something about that ... internet link...

Exemple like that (is not working...!)
========================
Server Name:ServerName1
User:user_srv1
Pass:pass_srv1
Server Name:ServerName2
User:user_srv2
Pass:pass_srv2

SELECT a.FieldID, b.FieldID FROM
ServerName1.DatabaseName.dbo.TableName a,
ServerName2.DatabaseName.dbo.TableName b
WHERE a.FieldID=b.FieldID
=========================

THANKSYou should be creating linked server to access the database on a remote server. You could create the linked server and the login on the fly and drop them after you are done with your code. check out BOL for creating the linked server.

-cbarus

No comments:

Post a Comment