Hi!
I have a Server with 2 SQL instances on it. 1 is a deafult instance and the other is a named instance:
Servername SPING
Default instance SPING\MSSQLSERVER
Names Instance SPING\PARIS
When I run an invoke SQL command it always connects to the default instance, no matter what I specify. Does anyone know how to tell it to connect to the SPING\PARIS instance? Here is my code (I have tried it both with and without port numbers)
$instancename = "SPING\PARIS" $dbname = "testDB" Invoke-Sqlcmd -Query " declare @cmd nvarchar(2000) declare @out_cmd nvarchar(2000) set @cmd = 'set nocount on select @@servername' set @out_cmd = 'sqlcmd -Q ""' + @cmd + '"" >> c:\DecomOutput1.txt' EXECUTE master.dbo.xp_cmdshell @out_cmd" -ServerInstance $instancename -Database $dbname
When I run this it creates a file called DecomOutput1.txt and the file contains the default instance name SPING
Anyone know what im doing wrong?
Thanks,
Zoe