Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm guessing that using sqlcmd in some form from inside this script is going to be one of the answers but sitting here with ssmse open and a "new query" ready to be written ... there's gotta be some switch command in T-SQL where I can move between the instances.

Ultimately I wish to run a broad spectrum effect on each of several databases and composit the results.

All I can think of doing right now is to use "sqlcmd -i" naming the instance then another .sql script, to completion tabulating data, then run it again on the next instance ...

I believe the local->remote->local again is ok with that?

[EDIT_01]

I see sp_addlinkedserver in the towering list of things available in the programmability scripts to check out. All I might have to do is add the name of the "remote" database after linking in the "remote" server, right?
Posted
Updated 10-Oct-12 9:10am
v2

1 solution

Ok,

As can be seen from a post similar to this one, answered by Mehdi, I was getting FAIL on the technique as applied in the article. Today, I still couoldn't get the Quackit method to work. And as I stated there is some disparity between that article and ssmse help on "sp_addlinkedserver".

But Mehdi's clue is what guided me to this sto-proc so he deserves credit even though using the help was how the solution is implemented:

A simple T-SQL statement in the local instance script with connection focal to "COMPUTER_A\localServer":

USE master
GO
EXEC sp_addlinkedserver
N'COMPUTER_A\closeServer'
N'SQL Server';
GO

Makes the Server Objects "Linked Servers" on localServer instance dropdown under the new COMPUTER_A\closeServer -> Catalogs list light up like a christmas tree with fullsome goodness!

And then all that one needs to do is QUERY using the TABLE name.

(caveat emptor:

And mighty strangely at that ... trying to QUERY a table using this form

[data].[dbo].[essential]

Won't do. Only

[dbo].[essential]

Works. )

[EDIT_FINAL]

And intuitively the BEST way to query the table

SELECT * FROM [COMPUTER_A\closeServer].[data].[dbo].[essential]

[END EDIT_FINAL]
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900