sqlcmd not running - sql-server-2012

I am not a SQL specialist, but I really need to use the sqlcmd utility.
I have installed
but when I run sqlcmd, I get
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn>sqlcmd
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Named Pipes Provider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : A network-related or instance-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 if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
Can you give a help hand please ?
I really need to attach a .mdf file to my SQL Server 2012 machine

May be you are missing the instance name -
usage:
sqlcmd -S <ComputerName>\<InstanceName>

Related

How to access SQL Server?

The problem: I'm getting this error:
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server)
Program files shows this:
MSSQL13.SQLEXPRESS
MSSQL14.SQLEXPRESS
MSSQL14.SQLEXPRESS01
I can access MSSQL14.SQLEXPRESS01 from SSMS 17.9.1, but all of my databases are in MSSQL13.SQLEXPRESS.
Installation:
SQL Server Management Studio 17.9.1
Visual Studio 2019 16.2.1
How can I access the databases in MSSQL13.SQLEXPRESS?
Turns out that "for some reason" SQL Server Services for SQL Server express was not running.
After I used services.msc to start it, I was able to open the SQL Server 13 engine (SQL Server 2016) and see all of my "old" databases.
Thanks to Vivek Janakiraman for providing a solution on the MSDN SQL Server forum.

Integration Tests using localdb with Visual Studio Online Errors - 'contained database authentication' must be set to 1

I am using localdb for some Entity Framework repository integration unit tests.
I have implemented a standard build configuration and after initial problems read that I should initialise and start the SQL Local DB.
To that end I added the following to test project post-build:
"C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" create "V12.0" 12.0 -s
but I was getting errors locally and in Visual Studio Online Build like:
The sp_configure value 'contained database authentication'
must be set to 1 in order to create a contained database.
You may need to use RECONFIGURE to set the value_in_use.
So after some research I then added the following.
sqlcmd -S "(localdb)\V12.0" -Q "EXEC sys.sp_configure N'contained database authentication', N'1';"
sqlcmd -S "(localdb)\V12.0" -Q "RECONFIGURE WITH OVERRIDE;"
This fixed things locally, but in VSO build agent I still get errors. It appears that the localdb is initialized OK, but then the SQLCMD can locate the server instance just created. Log below.
"C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" create "V12.0" 12.0 -s
sqlcmd -S "(localdb)\V12.0" -Q "EXEC sys.sp_configure N'contained database authentication', N'1';"
sqlcmd -S "(localdb)\V12.0" -Q "RECONFIGURE WITH OVERRIDE;"
LocalDB instance "V12.0" created with version 12.0.2000.8.
LocalDB instance "V12.0" started.
HResult 0xFFFFFFFF, Level 16, State 1
SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].
Sqlcmd(0,0): Error : Microsoft SQL Server Native Client 10.0 : A network-related or instance-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 if 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 : A network-related or instance-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 if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.. [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsettings.repository.Tests\hms.entappsettings.repository.Tests.csproj]
Sqlcmd(0,0): Error : Microsoft SQL Server Native Client 10.0 : Login timeout expired.
Sqlcmd : error : Microsoft SQL Server Native Client 10.0 : Login timeout expired. [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsettings.repository.Tests\hms.entappsettings.repository.Tests.csproj]
HResult 0xFFFFFFFF, Level 16, State 1
SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].
Sqlcmd(0,0): Error : Microsoft SQL Server Native Client 10.0 : A network-related or instance-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 if 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 : A network-related or instance-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 if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.. [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsettings.repository.Tests\hms.entappsettings.repository.Tests.csproj]
Sqlcmd(0,0): Error : Microsoft SQL Server Native Client 10.0 : Login timeout expired.
Sqlcmd : error : Microsoft SQL Server Native Client 10.0 : Login timeout expired. [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsettings.repository.Tests\hms.entappsettings.repository.Tests.csproj]
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4714,5): Error MSB3073: The command ""C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" create "V12.0" 12.0 -s
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4714,5): error MSB3073: The command ""C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" create "V12.0" 12.0 -s [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsetting
Any help would be greatly appreciated.

Local MS SQL 2008 R2 Server: Could not open a connection to SQL Server[2] (and [52])

I am trying to connect to a server installed on the same machine that I am using. I installed it using mixed mode. I try to connect using the following command:
sqlcmd .\SQLEXPRESS -Usa ...and then I enter my password.
However, I then get the following error:
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 instance-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 if 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.
I have made sure that Named Pipes and TCP/IP is enabled.
I also get the same error but the error code is [52] if I don't put in the user/pass.
I am using Windows Server 2008 R2 for my OS, if it matters.
Thanks for the help!
EDIT 1: Service: "SQL Server (SQLEXPRESS)" is started.
Turns out I have to run this in powershell.

can't connect to Sql Sever Management Express 2012

I installed Sql Sever Management Express 2012 , but when i try to connect in Sql management studio environment , i have this error .
ADDITIONAL INFORMATION:
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) (Microsoft SQL Server, Error: 2)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=2&LinkId=20476
The system cannot find the file specified
BUTTONS:
OK
and in during installation i dont have option for select cluster !!
this is my SQL Server Configuration Manager , my sql server service is empty ...
And when get Remove a Failover Cluster Node , this error happened .
http://oi57.tinypic.com/2lrvat.jpg
when i enter SQLEXPRESS , i have error
Cannot connect to SQLEXPRESS. ------------------------------
ADDITIONAL INFORMATION: 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) (Microsoft SQL Server, Error: 53)
Viewing your linked images, is clear that you haven't installed or installed unsuccesfully,
Sql Server Express 2012
In your Configuration Server Manager there is no instancse of SQL Server so it is normal not been able to connect.
Q: Sine there is no instance,when you Launch Management Studio what instance name do you select when you try to connect???
You should properly install SQL Server Express 2012
EDIT :
First Check if you have any version of SQL Server or SQL Server Express installed on your machine...(this can be done by looking through installed programs from control panel)
In order to Install and configure SQL Express 2008 follow this steps
Take in mind that you have to use SQL Management Studio 2008 later on (if you have 2008 server)
Hope it helps...

SQL Server 2008 Express and windows authentication

I have a SQL Server 2008 Express instance running and I can access the server with the default account sqlexpress using sqlcmd.
Now I have created a new windows account on the machine where SQL Server is running and created a login for sqlexpress using windows authentication. This account would be specifically used for backups.
When I try to login using the following and run the backup script (this backup script works fine for the default account sqlexpress)
sqlcmd -S (local)\mywinusr -i TestBkup.sql
I get the error
HResult 0xFFFFFFFF, Level 16, State 1
SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or instance-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 if 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. tting login failed for the user.
What could be the problem?
sqlcmd -S specifies a server, you have specified (local)\mywinusr. this suggests that you are passing in a username as an instance. your server name for sqlexpress should be:
(local)\sqlexpress
if you are logged inas this new user, then you just specify -E for 'trusted connection'
if you need to connect as, use
-U domain\username and -P password
hope this helps