I am attempting to move msdb (SQL Server 2005) by using the instructions here:
http://support.microsoft.com/kb/224071
However, when I start SQL Server in single user mode, I have no way to access the database. I have tried starting sqlcmd from the console (and also for good measure tried starting ssms), but I'm unable to get into any tool to do my work because it says it is in single user mode and only one administrator can be logged in. In the services console I see no other SQL Server related processes running, so what is preventing me from getting in?
Thanks...
Some application is stealing the only connection available. See Starting SQL Server in Single-User Mode for a tip how to prevent that:
When you use the -m option with sqlcmd or Management Studio, you can
limit the connections to a specified client application. For example,
-m"sqlcmd" limits connections to a single connection and that
connection must identify itself as the sqlcmd client program. Use this
option when you are starting SQL Server in single-user mode and an
unknown client application is taking the only available connection. To
connect through the Query Editor in Management Studio, use
-m"Microsoft SQL Server Management Studio - Query".
Related
My organization had a security audit and was told that we need to DISABLE the "allow remote connection to this server" option for all of our SQL Servers. What impact would this have on connection to the SQL Server via Management Studio (SSMS) from a client machine/desktop or from a web app that might use a connection string or any other external app? All of the documentation I see regarding connectivity issues to a SQL Server seem to include "ENABLING" this option as a solution. Is there a workaround that will allow us to disable it but still allow the access we need from the target clients?
We have multiple versions that we would be doing this on 2012, 2014, 2016 and 2017.
The "allow remote connection to this server" option in SSMS (Server Properties-->Connections) is actually the remote access configuration option. This option is often mistaken for enabling remote network connectivity via SQL Server Configuration Manager, which might be what you've read.
The remote access option is a long deprecated feature that will be removed in a future SQL Server version. It will likely have no impact but your environment may be atypical so you may want to first test in a pre-prod environment before making the change in prod.
Below is the excerpt from the documentation.
The remote access option controls the execution of stored procedures
from local or remote servers on which instances of SQL Server are
running. This default value for this option is 1. This grants
permission to run local stored procedures from remote servers or
remote stored procedures from the local server. To prevent local
stored procedures from being run from a remote server or remote stored
procedures from being run on the local server, set the option to 0.
When using SQL Server Management Studio I try to query a DB created with "Single user" restrictions.
I log in by using SQL Credentials and "sa" user and by running sp_who2 command I double check nobody is connected to the DB, nevertheless when executing a query on a DB table, the system replies:
Database 'MyDB' is already open and can only have one user at a time.
I'd like to understand why I am experiencing this issue.
Can anybody help on this?
When you set a db in "single user" mode you can only open a single connection to the database (more info here).
So when you open SSMS to navigate through database objects you open the only permitted connection. After this any other operation that requires a new connection to the db will fail, for example creating a new query window to write a query.
From MS Docs:
When you start an instance of SQL Server in single-user mode, SQL Server Management Studio can connect to SQL Server. Object Explorer in Management Studio might fail because it requires more than one connection for some operations. To manage SQL Server in single-user mode, execute Transact-SQL statements by connecting only through the Query Editor in Management Studio, or use the sqlcmd utility.
The same happens on premise if you have the SQL Server agent running.
Another advice from MS Docs (if you are running SQL Server on premise):
Stop the SQL Server Agent service before connecting to an instance of SQL Server in single-user mode; otherwise, the SQL Server Agent service uses the connection, thereby blocking it.
Here's my problem: I have an application which uses sql server express 2005, and it is installed under default sql server express instance, SQLExpress
Under this instance there are several other databases, used by other applications (web based or desktop)
If I need to restore the database, sometimes it works, but sometimes it fails, telling that I need exclusive access to database to do this. I understand that, and of course when I try to restore, the application using the db is closed, but probably it was just closed minutes before so sql server still keeps some connections open, for caching purpose.
And in this case I have two options:
restart the sql server instance -
that's easiest to do from user point
of view(right click on server
connection in Enterprise Manager and
select restart (but worst since this
stops all databases)
Detach my db, attach again then restore (this works because detach
have option to close all
connections). But this is harder to
do (takes more time) since I have to
browse through the folders to find
where db is located to attach back (I
keep all db's in a custom location,
not under default sql server database
location)
My question is, is there any other easier way to do this?
Thanks
In SQL server Management Studio (not sure about Express, I'll check) you can use the Activity Monitor under Management to locate any connections still open to the database. Right-click the connection and choose 'Kill'
This way you can clear any outstanding connections.
[EDIT] I've checked a SQL server Express, and it also contains the Activity Monitor.
Alternatively you can use a script to close all connections. See here for an example.
I recently installed SQL2008 and am having trouble logging in from another application. I have set the security to shared authentication and have specified a password for the SA login. I am able to log in using SA and password from the management studio and also from command prompt using the osql command, but when trying to log in from third party software (specifically, WhereNet VSS) I get the popup "The SQL Instance Name or login information is not correct. Please try again."
Any suggestions? Unfortunately I cannot install the software until I can successfully log in to the SQL server so it is critical that I get past this ASAP.
Thanks,
Joseph
Did you enable remote connections to your SQL Svr instance (see Server Properties, Connections)? Also, make sure the Windows (or proprietary) firewall isn't interfering w/ connectivity.
Other than allowing remote connections from SQL Server Instance properties --> connections - did you configure remote connections from SQL Server Surface Area Configuration tool? If not you might wanna play with those options to enable remote connections over TCP/IP and/or named pipes.
Also - did you check from the Configuration Manager Tool if TCP/IP properties are properly configured (TCP port properly set, etc.)
Did you try to do the same stuff on another machine and see if with the same settings it works?
I have a desktop, and a Laptop. The Desktop has Windows 7 64-bit and the Laptop has Vista Ultimate 32-bit. On both machines I have SQL Server 2008 Standard installed.
On the laptop, I open SQL Management Studio and try to connect to the SQL Server on the desktop. It times out.
With SQL Server Config Manager I Enabled TCP/IP and Named Pipes for the client protocols.
In SQL Management Studio, I right clicked on the Database Engine, went to properties, and allowed remote connections. I also created a sql server login named "testuser" and a password. I then added that user as a login for my database and made them the database owner.
I could not figure out how to allow connection to my db throw the windows firewall, so I turned it off.
What am I missing? I made the same changes on my laptop, and I can connect from the Desktop to the Laptop in Management Studio?
Do you have a checklist?
Thanks.
UPDATE:
I turned off antivirus. Ran NetStat -a and the listener is listening.
If your login attempt takes about 30 seconds to timeout, then it's some kind of network connectivity problem (or SQL isn't listening properly). A permissions problem would come back after a few seconds, so the long wait says it's connection-related.
If you run "NETSTAT -a" on the server, so you see SQL Server listening on port 1433? If not, then maybe the SQL TCP Listener isn't configured properly on the server - there should be events in the Windows Event log to this effect when the SQL Service starts up.
Please edit your question with the results and we can go from there.
Try using Telnet to see if the laptop can see the desktop via port 1433.
Open a command prompt on the laptop and enter:
telnet DesktopNameOrIPAddress 1433
Press Enter, and you should either see a connection failed error, or a blank screen. If you get the blank screen, the connection was established. Press CTRL-] to break out of it, then type "quit" and enter to quit.
If the connection failed, attempt to resolve the general network issue with port 1433 before bothering to use the SQL Server tools.
If you have any other anti-virus software running, it may also have a firewall built in. I know that McAfee does, for instance. Check for that.
You've probably already thought of this, but have you checked that the server is configured to allow Mixed Mode Authentication? I have not had access to 2008, but I seem to remember that at least one of the previous versions was configured to disallow sql logins by default.
I assume you already did what you have to do on the OS level. Or maybe tried to link the server to see if you can actually traverse your network. Let me suggest a quick test. Check if you can actually test connectivity by creating a Universal Data Link. In case you don't know how to do this, create a new text file in your desktop (or anywhere) and change the .txt file extension to .udl; then just open it. See if your other server is "viewable" over the network (Don't forget to change the Provider to OLE DB Provider for SQL Server).
Is the SQL Browser Service running on the server you are trying to access? (By default this is disabled, and you'll need that to access SQL Server remotely)