dbTalk Databases Forums  

sqlcmd

microsoft.public.sqlserver.setup microsoft.public.sqlserver.setup


Discuss sqlcmd in the microsoft.public.sqlserver.setup forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gene Wirchenko
 
Posts: n/a

Default sqlcmd - 10-25-2010 , 01:50 PM






Hello:

Now that I have SQL Express, I am going back over the tutorials
that I did before.

I had trouble with sqlcmd. If I give the plain command
sqlcmd
I get
HResult 0x2, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A
network-related or in
stance-specific error has occurred while establishing a connection to
SQL Server
.. Server is not found or not accessible. Check if instance name is
correct and i
f SQL Server is configured to allow remote connections. For more
information see
SQL Server Books Online..
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout
expired.

If I specify my server, it works. Shouldn't the plain command
work since it is supposed to start the default instance of SQL Express
on my computer?

I accepted the default instance name when installing SQL Express.

SSMS works: it starts up and I can log in.

Sincerely,

Gene Wirchenko

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: sqlcmd - 10-25-2010 , 04:33 PM






Gene Wirchenko (genew (AT) ocis (DOT) net) writes:
Quote:
If I specify my server, it works. Shouldn't the plain command
work since it is supposed to start the default instance of SQL Express
on my computer?
No.

Admittedly, this is a little confusing. A default instance is an instance
that does not have a name. It is accessed as SERVER only. A named instance
is accessed as SERVER\NAME.

If you install any other edition than Express, then by default you get a
default instance.

But when you install Express Edition, by default you get a named instance
with the name SQLEXPRESS. Why, you may wonder? Because you may install
some other edition later. And more importantly, you may bundle Express
with an application you sell, and in that case you should hijack the
default instance, in case the customer wants to install a bigger instance of
SQL Srever later.


Quote:
SSMS works: it starts up and I can log in.
In SSMS Server\instance is filled for you.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Reply With Quote
  #3  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: sqlcmd - 10-26-2010 , 01:22 PM



On Mon, 25 Oct 2010 23:33:40 +0200, Erland Sommarskog
<esquel (AT) sommarskog (DOT) se> wrote:

Quote:
Gene Wirchenko (genew (AT) ocis (DOT) net) writes:
If I specify my server, it works. Shouldn't the plain command
work since it is supposed to start the default instance of SQL Express
on my computer?

No.

Admittedly, this is a little confusing. A default instance is an instance
^^^^^^^^
ITYM "unnecessarily".

I think one could be forgiven for thinking that Microsoft does
not want its product used.

[snip]

Sincerely,

Gene Wirchenko

Reply With Quote
  #4  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: sqlcmd - 10-26-2010 , 04:44 PM



Gene Wirchenko (genew (AT) ocis (DOT) net) writes:
Quote:
Admittedly, this is a little confusing. A default instance is an instance
^^^^^^^^
ITYM "unnecessarily".

I think one could be forgiven for thinking that Microsoft does
not want its product used.
No, the current behaviour is correct in my opinion. SQL Express should
not be installed as a default instance, at least no by default, and SQLCMD
should not try to guess what you want. What if you later install a
default instance, and SQLCMD without any arguments suddenly started to
connect to a difference instance?

If ./SQLEXPRESS to much to type for you, I think SQLCMD can get the default
server from a environment manual. Books Online should have the details.
--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Reply With Quote
  #5  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: sqlcmd - 10-26-2010 , 05:13 PM



On Tue, 26 Oct 2010 23:44:31 +0200, Erland Sommarskog
<esquel (AT) sommarskog (DOT) se> wrote:

Quote:
Gene Wirchenko (genew (AT) ocis (DOT) net) writes:
Admittedly, this is a little confusing. A default instance is an instance
^^^^^^^^
ITYM "unnecessarily".

I think one could be forgiven for thinking that Microsoft does
not want its product used.

No, the current behaviour is correct in my opinion. SQL Express should
I do not. "default" means the one selected when nothing is
specified. I think that most people would think that when there is
only one, that it should be the default.

Microsoft has chosen to call a nameless instance a default
instance. Was there really any need for this obfuscation?

Quote:
not be installed as a default instance, at least no by default, and SQLCMD
should not try to guess what you want. What if you later install a
default instance, and SQLCMD without any arguments suddenly started to
connect to a difference instance?
People are familiar with defaults changing.

Quote:
If ./SQLEXPRESS to much to type for you, I think SQLCMD can get the default
server from a environment manual. Books Online should have the details.
^^^^^^
ITYM "variable" here.

No such option, but one could do
set inst=Loop\SQLExpress
sqlcmd -S %inst%
or
set inst=-S Loop\SQLExpress
sqlcmd -%inst%

I just created a batch file consisting of this line:
sqlcmd -S Loop\SQLExpress %*

It is these little gotchas and the sheer number of them that
makes SQL Server difficult to learn.

Sincerely,

Gene Wirchenko

Reply With Quote
  #6  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: sqlcmd - 10-27-2010 , 02:25 AM



Gene Wirchenko (genew (AT) ocis (DOT) net) writes:
Quote:
Microsoft has chosen to call a nameless instance a default
instance. Was there really any need for this obfuscation?
Everything has a history. In the beginning there was no named instances, but
you only could only have one instance of SQL Server on a machine. That was
in SQL 2000. SQL Express was introduced in SQL 2005.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
  #7  
Old   
Hugo Kornelis
 
Posts: n/a

Default Re: sqlcmd - 10-27-2010 , 05:27 AM



On Tue, 26 Oct 2010 15:13:57 -0700, Gene Wirchenko wrote:

Quote:
I do not. "default" means the one selected when nothing is
specified. I think that most people would think that when there is
only one, that it should be the default.
Don't forget that SQL Server is a server product by nature. The client
tools don't necessarily expect the server to be on the same computer as
where they are running. In such a setup, it's hard to come up with any
sensible default, so I think not having a default to connect to is the
right choice.

Quote:
Microsoft has chosen to call a nameless instance a default
instance. Was there really any need for this obfuscation?
Probably the fact that if you change no options during installation of
SQL Server, you get a nameless instance. It's not the default to connect
to, but the default to install.

Quote:
If ./SQLEXPRESS to much to type for you, I think SQLCMD can get the default
server from a environment manual. Books Online should have the details.
^^^^^^
ITYM "variable" here.

No such option,
Wrong. Excerpt from Books Online:
"If you do not specify a server_name [ \instance_name ] when you start
sqlcmd, SQL Server checks for and uses the SQLCMDSERVER environment
variable."

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis

Reply With Quote
  #8  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: sqlcmd - 10-27-2010 , 02:53 PM



On Wed, 27 Oct 2010 12:27:04 +0200, Hugo Kornelis
<hugo (AT) perFact (DOT) REMOVETHIS.info.INVALID> wrote:

Quote:
On Tue, 26 Oct 2010 15:13:57 -0700, Gene Wirchenko wrote:

I do not. "default" means the one selected when nothing is
specified. I think that most people would think that when there is
only one, that it should be the default.

Don't forget that SQL Server is a server product by nature. The client
tools don't necessarily expect the server to be on the same computer as
where they are running. In such a setup, it's hard to come up with any
sensible default, so I think not having a default to connect to is the
right choice.
Funny that the Microsoft tutorial does not agree.

Well, not so funny. I have not found it very useful. I have
found out about a book that looks hopeful, previewed a chapter, and
have just ordered it.

Quote:
Microsoft has chosen to call a nameless instance a default
instance. Was there really any need for this obfuscation?

Probably the fact that if you change no options during installation of
SQL Server, you get a nameless instance. It's not the default to connect
to, but the default to install.
Nameless instance is not the default.

Quote:
If ./SQLEXPRESS to much to type for you, I think SQLCMD can get the default
server from a environment manual. Books Online should have the details.
^^^^^^
ITYM "variable" here.

No such option,

Wrong. Excerpt from Books Online:
"If you do not specify a server_name [ \instance_name ] when you start
sqlcmd, SQL Server checks for and uses the SQLCMDSERVER environment
variable."
Not wrong. I looked at the command options, and there was no
such option.

Your detail is YA detail that is not obvious to someone starting
and is just another gotcha.

Sincerely,

Gene Wirchenko

Reply With Quote
  #9  
Old   
Hugo Kornelis
 
Posts: n/a

Default Re: sqlcmd - 10-28-2010 , 08:41 AM



On Wed, 27 Oct 2010 12:53:46 -0700, Gene Wirchenko wrote:

Quote:
Probably the fact that if you change no options during installation of
SQL Server, you get a nameless instance. It's not the default to connect
to, but the default to install.

Nameless instance is not the default.
It's not the default for Express. But it has always been the default for
other SQL Server editions. As Erland already mentioned, Express was
introduced a lot later than the other SQL Server editions. The name
"default instance" was already in use when Express was released.

Quote:
If ./SQLEXPRESS to much to type for you, I think SQLCMD can get the default
server from a environment manual. Books Online should have the details.
^^^^^^
ITYM "variable" here.

No such option,

Wrong. Excerpt from Books Online:
"If you do not specify a server_name [ \instance_name ] when you start
sqlcmd, SQL Server checks for and uses the SQLCMDSERVER environment
variable."

Not wrong. I looked at the command options, and there was no
such option.

Your detail is YA detail that is not obvious to someone starting
and is just another gotcha.
Now I don't understand. I thought this was about environment variables,
but now you say that this is not a command option. Just for the record,
when running sqlcmd.exe ...

* You can use the -S command line option to specify server name or
server + instance name to connect to. This is documented in Books
Online. When you run sqlcmd with the -? option, -S in included in the
overview, but [\instance] is missing (tested on SQL Server 2005; I have
no idea if this is fixed in later edition, but I'll run a test later)

* Or you can set the SQLCMDSERVER environment variable before running
sqlcmd.exe. This environment variable will only be used if the -S option
is not specified. This is documented in Books Online.

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis

Reply With Quote
  #10  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: sqlcmd - 10-28-2010 , 09:53 AM



On Thu, 28 Oct 2010 15:41:59 +0200, Hugo Kornelis
<hugo (AT) perFact (DOT) REMOVETHIS.info.INVALID> wrote:

[snip]

Quote:
Now I don't understand. I thought this was about environment variables,
but now you say that this is not a command option. Just for the record,
when running sqlcmd.exe ...

* You can use the -S command line option to specify server name or
server + instance name to connect to. This is documented in Books
Online. When you run sqlcmd with the -? option, -S in included in the
overview, but [\instance] is missing (tested on SQL Server 2005; I have
no idea if this is fixed in later edition, but I'll run a test later)
-S is a command option.

Quote:
* Or you can set the SQLCMDSERVER environment variable before running
sqlcmd.exe. This environment variable will only be used if the -S option
is not specified. This is documented in Books Online.
This is not a command option. It is not documented in the
command help. I had no reason to suppose it existed, so why would I
go looking? Just think of how nice it would have been if this was
part of the sqlcmd /? output:

"If the -S parameter is not specified, sqlcmd will use the value
of the SQLCMDSERVER environment variable (if defined) for the server
string."

The secret to eternal life could be hidden in the Books Online
for all I know. "hidden" is the operative word.

Sincerely,

Gene Wirchenko

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.