Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Of great importance is the added fact that these instances are linked as servers and they show the proper property as such in "Linked Servers" where each's catalog can be viewed.

The problem for me is that I can't specifically write a statement like this:
SQL
SELECT * FROM [COMPUTER_A\INSTANCE_01].[knowndatabase].[dbo].[knowntable]

Given the fact that INSTANCE_01 is not currently under the "USE" control within the executing interface of ssmse. Nor can I do the general sys.all_objects type of query in a loop using that same [COMPUTER_A\INSTANCE_01].sys.all_objects "expectation".

Is this question clear enough?

[EDIT]

An idea:
SQL
DECLARE @nullscript varchar(4000)
SET @nullscript = 'sqlcmd -S COMPUTER_A\INSTANCE_01 '
EXEC xp_cmdshell @nullscript

(to view what databases are now available):
SQL
SELECT * FROM sys.master_files WHERE data_space_id = 1

(And unfortunately unfruitful next to test):

SQL
DECLARE @nullscript2 varchar(4000)
SET @nullscript2 = 'sqlcmd -S COMPUTER_A\INSTANCE_02 '
EXEC xp_cmdshell @nullscript2

(Get the INSTANCE_01 tables .. drat):
SQL
SELECT * FROM sys.master_files WHERE data_space_id = 1

No change of the INSTANCE from _01 to _02

[END EDIT]
Posted
Updated 26-Oct-12 9:47am
v4

1 solution

The solution:

There is no solution only a workaround. SSMSE will not allow another instance to be addressed after initializing a particular server, outside of committing to the use of the interface button via mouse.

A workaround to circumvent ssmse interface altogether is of the form, after sp_addLinkedServer is deployed,

EXECUTE xp_cmdshell 'sqlcmd -S COMPUTER_A\INSTANCE_01 -q " ... "'

And

EXECUTE xp_cmdshell 'sqlcmd -S COMPUTER_A\INSTANCE_02 -q " ... "'

To do the dirty work.

There is to be expected from this xp_cmdshell/sqlcmd lever only text output (or other hbn considering the ssmse options available) but very tough operations where tables are mirrored or complex operations during maintenance or upgrade are created or refreshed should perform as expected.
 
Share this answer
 

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