SQL Server 2008 Express and windows authentication - sql-server-2008-express

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

Related

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.

Error connecting to new sql server

I am facing problem in registering new sql server instance SQLEXPRESS in SQL Management studio 2008. when I try to connect or test the server error message appear,
I am also facing facing same problem in any new server irrespective of the name, except the main one which was created at the time of installation and which was named same as my user ID in windows..
TITLE: Microsoft SQL Server Management Studio
Error connecting 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)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=53&LinkId=20476
are you using windows authentication or sql server authentication
if you are using windows authentication then you have to give the sql instance name
which sql provide by default .
if you using sql authentication then u must use the username and password which
you provide during setup

Cannot connect to sql server 2008 using JDBC

I have tried all the methods to connect to the server.I am using sql server 2008 on mixed authentication mode.I can login via the sql server management studio using the sa login.But when I try accessing the same db from my java program I get the following error:
SQL Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'sa'. ClientConnectionId:191d94bb-a55e-47a0-bb9f-b84638313cf4
This is my connectionstring:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl= "jdbc:sqlserver://localhost;databaseName=Northwind;user=sa;password=sa;";
I have accessed my database in the same way. One of my problems were that I hadn't enabled the port and IP for the database. Check these options in SQL Server Configuration Manager. Hope this helps =)

How to login to SQL Server 2005 Express Management Studio?

I've just installed SQL Server 2005 Express and I'm trying to login to Management Studio but I don't know what the "Server Name" is to be able to login.
I've tried:
localhost\SQLEXPRESS
127.0.0.1\SQLEXPRESS
SQLEXPRESS
<computer name>\SQLEXPRESS
<username>\SQLEXPRESS
The authentication mode is Windows Authentication.
The error message I'm getting is:
Could not connect to <computer name>\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. (proveder: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server)
Does anyone point me in the right direction?
Is the SQL Server Express service even up and running??
The local machine can be defined as . or (local) for SQL Server, and the SQL Server Express instance name is SQLExpress by default.
So .\SQLExpress or (local)\SQLExpress ought to work.
If they don't, maybe the service isn't up and running??