Click here to Skip to main content
11,934,389 members (50,492 online)
Rate this:
Please Sign up or sign in to vote.
See more: T-SQL
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?


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 10-Oct-12 10:03am
Edited 10-Oct-12 10:10am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


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
EXEC sp_addlinkedserver
N'SQL Server';

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


Won't do. Only


Works. )


And intuitively the BEST way to query the table

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


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 10 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100