SQL Server 2014 can't login after detach database - sql

I'm using using Windows server and I'm having trouble logging in to SQL Server 2014.
A few days ago I changed default user from master database to new one. But today I opened SQL Server Management Studio.
I detach that database by right-clicking on it. After that, I disconnect from SQL Server Management Studio and then connect again.
Check: Windows authentication
Click OK
I get an error:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (.Net SqlClient Data Provider) error:233
When I try more to fixed it, now I get this error:
Login Failed for user A. Reason: Server is in single user mode. Only one administrator can connect at this time (Microsoft SQL Server, Error: 18461)
What causes this error and how do I login again and attach my database?
Can I login to master database?

One way to solve this is by starting SQL instance in minimum config mode.
NET START MSSQLSERVER /f
Once you connect to the instance from same cmd window, then change the Max memory setting :
SQLCMD -S <ServerName>\<InstanceName> -E
A prompt occurs:
1>
Type the following:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'max server memory', 4096;
GO
RECONFIGURE;
GO
Restart the instance from Configuration Manager.
More on sqlcmd here:
https://learn.microsoft.com/mt-mt/sql/ssms/scripting/sqlcmd-use-the-utility?view=sql-server-2017

Related

SQL Linked server - Remote access error when executing SP

I've set up a linked server between an instance on SQL 2012 and SQL 2008R2 but
I keep getting the below error when trying to execute a stored procedure on a remote server:
Msg 7201, Level 17, State 4, Line 1
Could not execute procedure on remote server 'TEST' because SQL Server is not configured for remote access. Ask your system administrator to reconfigure SQL Server to allow remote access.
I've checked on both servers and they're configured to allow remote connections. The login that I've used has sysadmin access on the remote server and I can see all the databases when I expand 'Catalogs' within the linked server. When I test the connection this also says it's connected successfully. The SQL Service account also has SA on both instances for what it's worth
The odd thing is when I run a simple select query on one of the tables within the database it shows a result but it doesn't seem to like the SP.
Select * from Linkserver.database.dbo.table
The above works fine but this SP doesn't:
EXECUTE Linkedserver.database.[dbo].[SP] ....
Any recommendation would be appreciated.
Despite being an old thread, forget about enabling remote access (and restart service) on remote server and try:
EXECUTE (N'database.[dbo].[SP]') AT Linkedserver
If you want to run SPs from Server B, then make Server B as the linked server in server A.
Run the script below in Server A, not B:
EXEC sp_configure 'remote access', 1; RECONFIGURE;
Then restart SQL Service in A.
Done.
Please first check your server properties if remote connections is allowed (related picture below). IF yes, use: exec nameofyourSP 'remote access', 1 reconfigure and try again.
First Run:
EXEC sp_configure 'remote access', '1';
RECONFIGURE;
You now need to restart MSSQLSERVER in order for the sp_configure command to take effect.
Once you restart it, run sp_configure again and notice that the run_value is 1 now. That's what you want.

Error: "The query builder failed. Cannot open user default database. Login failed. Login failed for user <User Name>"

I'm using Visual Basic Express 2010 and SQL Express 2008 in Windows XP.
At first I couldn't add a datasource (the .mdf file for the database) because of a "Operating system error 32" which I seemed to have resolved by giving myself full permissions for .mdf file (by right clicking on the file and going into properties and then Security) and restarting the SQL SERVER (SQLEXPRESS) service.
The dataset for the database is in my solution explorer but when I right click on a table adapter to add a query and attempt to open up the query builder, I get the error in the title above.
Ensure that SQL Express remote connections via TCP/IP and Named Pipes is enabled. You can refer to this article if you are not sure how to do that: How to: Configure Express to accept remote connections
Open SQL Server Management Studio and ensure that you can connect to the database.
Try reconnection from Visual Studio (Server Explorer window) using the same credentials.

MSSQL login authentication problems with ODBC connection and R stats package

I am trying to connect an ODBC source to the R statistical package but having log in problems.
I have set up the ODBC name eplR with an SQL server driver linking to the (local) server using windows NT authentication with the network login ID default. In the set up the data-source test is successful.
When I try and create the connection in R
library(RODBC)
channel <- odbcConnect("eplR")
I get a failed connection
Login failed for user pssguy-PC/pssguy - my local computer name
When I connect to the (local) SQL server 2005 via management studio with Windows authentication I get a similar error unless I open management studio
with the "run as administrator" option.
In management studio, if I look at the properties of the (local) server, the authentication is set to Windows authentication mode.
The permission to connect SQL grantor is sa and the Grant box is checked. There is also a connect sql permission for pssguy-PC\pssguy with an unchecked box. I check it but on restarting mssql server it has reverted to unchecked.
I had what I thought was an identical setup on another standalone machine and I have no problems connecting in R.
Any help much appreciated
Maybe with odbcConnect() you could try passing the uid and pwd arguments too?
i.e.
odbcConnect("eplR", "**USERNAME**", "**PASSWORd**")

SQL Server 2005 mixed mode authentication

just wondering is it possible to use mixed mode on sql server 2005 for user sa? I know how to do this in management studio but this isn't enough for user "sa". I think it needs done else where.
I am trying to connect to the database via a console app but keep getting the error "The account is disabled"
Cheers
Louis
Yes
http://msdn.microsoft.com/en-us/library/ms144284(v=SQL.90).aspx
How to:
http://msdn.microsoft.com/en-us/library/ms188670(v=SQL.90).aspx
If you didn't enable Mixed Mode Authentication during setup then you will need to do so in server properties > Security (you can use Management Studio - see above link). You will also need to enable the sa login and set an appropriate password.
Be sure to restart the SQL Service after changing the authentication mode for the changes to take effect.
If you are using SQL Express 2005 or you do not have SQL Server Management Studio installed you will need to update a registry key to enable Mixed Mode Authentication:
Open registry editor (launch
application %WINDIR%\regedit.exe) and
go to
HKLM\Software\Microsoft\Microsoft SQL
Server\MSSQL.1\MSSQLServer in the tree
on the left.
On the right, look for an entry named
LoginMode. The default value, when
installed is 1. Update it to 2. The
next step is to restart the service.
Launch your Service Manager (Start ->
Run -> Type services.msc) and look for
a service named MSSQL Server
(SQLEXPRESS). Restart the service.
Once the SQL Server service is restarted you then need to enable the sa account. Use the OSQL command line tool from an Administrator Command Prompt:
osql -E -S .\SQLEXPRESS
ALTER LOGIN sa ENABLE ;
GO
ALTER LOGIN sa WITH PASSWORD = '<password>' ;
GO
You should then be able to test the login using:
osql -U sa -S .\SQLEXPRESS
If you SQL Server is already configured for Mixed Mode Authentication, then you just need to enable the sa user. You can find it in the Security->Logins folder.

Getting Login error in sql server 2008

I have SQL server 2008 and it was working fine ,but today while starting SQL server I am getting the following 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)"
In SQL Server Configuration Manager--> sql server services --> MS sql server and all other service status is showing as stopped(previously it was running). I have tried to make it start but the request failed..I have checked the event log ,its showing "The SQL Server (MSSQLSERVER) service failed to start due to the following error:
The service did not start due to a logon failure" ....My SQL server is taking windows authentication and few days back I have changed the PWD ..can it b the reason..pls help.
Note: Its not remote connection..the server is My system only..
Thanks Stuart for ur suggestions but the problem was a bit different.
I got the sloution from http://dotnet.org.za/thea/archive/2004/06/09/2069.aspx
Its working Now :-)
In server properties in security, check that server authentication is set to
SQL SErver and Windows Authentication mode.
EDIT: I had similar error after installation of service pack, the install switched the server authentication mode to windows only.
1.Management Studio
2.Object browser should be open in the left hand pane
3.Right click on the server instance name
4.Select properties from the menu choices
5.Server Properties dialog opens
6.Select security on the left hand menu items
7.On the right, there will be server authentication, select 'SQL Server and Windows Authentication Mode'
This should allow you to log in as sa, once running and you are in, make changes if required to Logins and Roles