Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to named instance #550

Open
SSchwaiger opened this issue Oct 5, 2024 · 3 comments
Open

Cannot connect to named instance #550

SSchwaiger opened this issue Oct 5, 2024 · 3 comments

Comments

@SSchwaiger
Copy link

I'm running sqlcmd with an inline PowerShell task in a Azure DevOps pipeline.

The system diagnostic says: ##[debug]sqlcmd -S 'm-sql2022\UTF8,1433' -U 'abc' -P '***' -C -Q "CREATE DATABASE [LogDb]" -m -1

When the script is executed, the following error appears:

parse "sqlserver://abc:***@m-sql2022%5CUTF8:1433?app+name=sqlcmd&trustservercertificate=true": invalid URL escape "%5C"

Is this a bug or do I need to encode named instance addresses differently?

@LarnuUK
Copy link

LarnuUK commented Oct 28, 2024

The problem appears to be your connection string here. You specify both port and instance name (it should be one or the other). I would suggest trying:

sqlcmd -S 'm-sql2022\UTF8' -U ...

or

sqlcmd -S 'm-sql2022,1433' -U ...

Considering, however, your named instance is running on the default port (a very odd choice for a named instance), you could just completely omit the name/port too, as port 1433 would be used by default.

@DHCodi
Copy link

DHCodi commented Nov 5, 2024

Hi I have the same issue and it not using default port because I am connecting to failover group and the DBA decided to give a non standard port. I also have an instance name too that is not default. Anyway to specify port and instance

@shueybubbles
Copy link
Collaborator

If you know the port number, just use it, no need for the instance name.
If you don't know the port number, the browser service has to be running on the server so you can use the instance name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants