November 30, 2014 at 8:18 pm
I have the following script:
--Updated connection string
:CONNECT sql.mc.com -U [AdminAccount] -P [Password]
SELECT * FROM SYS.databases
GO
When I run three lines I receive the following error:
Connecting to sql.mc.com as sa...
Fatal scripting error. Cannot open connection specified in the SQLCMD script.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I have verified that my server address is correct as well as the login I am using. I am able to connect to sql.mc.com using SSMS with the credentials above. I also enabled SQLCMD by going to Query –> SQLCMD to enable SQLCMD in the query editor.
Any idea why I may be having this issue?
November 30, 2014 at 9:08 pm
No idea what the problem is but... I wouldn't use the SA login ever (most folks in-the-know will disable it on their servers) and I sure wouldn't embed the password for it in any script anywhere. My recommendation would be to use Windows Authentication even for experiments.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 9, 2014 at 6:09 am
Yeah, not smart. I am now using another login that has system and server roles.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply