Monday, March 26, 2012

Is it possible to have sqlcmd connect to local sqlexpress without a parameter?

(SQL Server Express 2005)

sqlcmd will connect to the local SQLExpress server just fine if I give the -S parameter:
SQLCMD -S .\SQLExpress

but is there any way to have it default to that so I can just say:
SQLCMD
?

Thanks,

dwh
You can do something like:
1) Create an Alias thorough Computer Management | SQL Server Configuration Manager | SQL Native Client Configuration
Alias Name: foo
Protocol: Named Pipes
Server: .\SQLExpress

2) Execute SQLCMD using the alias, like SQLCMD /S foo

Peter|||Umm... thanks, but that doesn't really help.

If I still need to say "sqlcmd /s foo", how is that any better than having to say "sqlcmd /s .\SQLExpress"?

Apparently on some machines here at work people are able to just say "sqlcmd" and it will default to the local SQL (Express) Server.

No?

Thanks,

dwh
|||They probably have a default instance installed. If /S is not specified, SQLCMD will try to connect to the dedfault instance. When installing Express, choose Advanced Options and then select "Default Instance". By default the Express setup installs Express and as a named instance called SQLEXPRESS.

To check whether they have a default or named istance, execute sp_helpserver against the server.

Peter

No comments:

Post a Comment