I can't use my server name in sql server mgmt studio - sql-server

I installed sql server mgmt studio 2008 r2. i used default instance (MSSQLSERVER) user name, added current user and used the default windows authentication. but when I logged in, i couldnt even logged unless i use "(local)" as server name. I tried using MSSQLSERVER, SomePCName\MSSQSERVER but still I couldnt log in. I tried enabling those protocols on Configuration manager but still I couldnt log in. Anyone here know how to fix this?

Run SQL Server browser service.
It's disabled by default.
Using Configuration Management tool(not ssms), enable the service and set start mode automatic.

Below are some points you can check
1) Disconnect your machine from network then on command prompt write following command
SQLCMD - L
The output of this command will be SQL SERVER name installed on your machine. You can use these names to connect.
If you face still the same issue then as my friend mentioned check browser service & SQL Server service whether they are up or not.

Related

Microsoft SQL Server , Error : 87

I am really tired, it's been 3 days that I can't open my SQL Server Management Studio. I got connection string error with number 87. Below screenshot show my problem:
And I use localhost\MSSQLSERVER with error 87 and Arash-PC (my machine name) with error number 2.
And I tried sqlcmd -U sa -S Arash-PC too
You need to check in your SQL Server Configuration Manager what services and instances you have installed. Go to Start Menu > All Programs > Microsoft SQL Server (version) > Configuration Tools and launch the appropriate Configuration Manager. You should see a screen something like this:
Find the SQL Server (.....) service(s), and make sure the service is started.
If you find a SQL Server (MSSQLSERVER) service started, then you have a (unnamed) default instance to which you can connect using
.
(local)
Arash-PC
You MUST NOT supply the MSSQLSERVER as the instance name!
If you find any other SQL Server (instance name) service started (e.g. SQL Server (SQLEXPRESS) in my screenshot), then the instance name (SQLEXPRESS) needs to be appended to the server name to connect to that instance:
.\SQLEXPRESS
(local)\SQLEXPRESS
Arash-PC\SQLEXPRESS
Make sure you are not running out of space on the drive where SQL is installed. Try rebooting as well.
Verify that the SQL Server (MSSQLSERVER) service is started. Click Start, click Administrative Tools, click Services, and scroll to SQL Server (MSSQLSERVER). If it is not started, right-click the service, select Properties, in Startup Type select Automatic, click Apply, click Start, and then click OK. Make sure service started. If service did not start - you need to analyze event log. Alternatively - try reinstalling/repairing SQL server.
Make sure you have no network problems - try temporary disabling any firewalls(including Windows Firewall) and antiviruses.
If service is started and firewalls disabled but still no luck - time to check SQL Server Configuration Manager settings. In detail it is described here and here. Shortly I would recommend first enable all protocols in both server and client sections. Reboot. Check it works. If that would not help - then try disabling everything apart from TCP/IP (both server and client sections). Reboot again.
If above does not help - try reinstalling SQL Server. Just make sure you have saved your databases 1st. To save them - stop sql server service, and copy your *.mdf and *.ldf (from SQL server Data folder) files to safe location. Later on you can attach them. If you are not sure where your SQL server Data folder located - just search for files with mdf extension.
Edit:
Successful telnet showing SQL server port is up looks this way:
Edit2:
Launch Event Viewer:
Click System, then Filter Current Log:
Setup filter as shown below:
Then look for SQL-related events:
Usually event text provides information why MSSQLSERVER service fails to start. If the text is unclear please google it for more details.
If your problem was the same as mine (or to anyone else whose attempting to connect to their MS SQL Server w/ a similar connection string), MSSQLSERVER is the default instance name when you set it up, if you don't provide an instance name. I omitted the MSSQLSERVER from the connection string and I was successfully able to connect.
With all respect to "Anton Kruglov" and "marc_s" , Unfortunately, my problem is not resolved . I had to change my windows and reinstall softwares . Now it works properly .

create database permission denied in database ‘master'-sql 2008 R2

So I have installed SQL Server 2008 R2 on windows 7 machine.I was able to login using my windows authentication.Now when I try to create a new database it gives me this error saying "CREATE DATABASE permission denied in database ‘master'".I have tried so many links related to this issue but still it is failing.These are the options that I tried:
1) Went to SQL Server Configuration Manager and then changed the parameters in the advanced tab by adding -m.It still did not help me.When I add this parameter and try to login again using windows authentication it gives me a message saying "Only one administrator can login as it is in single user mode".
2) While Installation I am sure that I added the current user under sysadmin role. I also made sure that the "Mixed mode authentication" is selected and then gave a password for the user "sa".Now when I try to use that password it says "Failed login for user sa".
3) When I login with windows authentication and then check the login mode by following this:
right click on main instance name-->Properties-->Security,it shows that only windows authentication mode is selected.But I am very much sure that I selected the "Mixed mode authentication".Not sure why it is showing it in this way.
4) I also tried to modify the password for sa but the current user has no permissions.I am not able to perform any operation with this user.
I know there are different links for this issue.But I tried all the options that were mentioned in those links but still it is giving me a problem.I have been trying to resolve this issue from a very long time.Could anyone suggest what I am missing here.
Solved! I had the same problem. I figured it out based on info from the article and the comments from the first commentor in this link.
I'll copy the author's steps with the necessary modifications in bold:
Open the Configuration Manager tool from the "SQL Server 2005| Configuration" menu
Stop the SQL Server Instance you need to recover (both SQL Server AND SQL Server Agent. Once in single user mode, if not stoped, the agent will tie up the connection, preventing you from using it with sqlcmd.exe).
In SQL Configuration Manager, click on SQL Server Services on the left, then right click on SQL Server on the right, navigate to the “Advanced” tab (or "Startup Parameters for more recent versions of SQL), and in the Properties text box add “–m” to the end of the list in the “Startup parameters” option.
Click the “OK” button and restart the SQL Server Instance (just SQL Server. Do not restart the SQL Server Agent just yet.) NOTE: make sure there is no space between “;” and “-m”, the registry
parameter parser is sensitive to such typos. You should see an entry
in the SQL Server ERRORLOG file that says “SQL Server started in
single-user mode.”
After the SQL Server Instance starts in single-user mode, the Windows Administrator account is able to connect to SQL Server using
the sqlcmd utility (it is probably here, or someplace very similar: C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE) using Windows authentication. You can use
Transact-SQL commands such as "sp_addsrvrolemember" to add an existing
login (or a newly created one) to the sysadmin server role. The
following example adds the account "Buck" in the "CONTOSO" domain to
the SQL Server "sysadmin" role: EXEC sp_addsrvrolemember
'CONTOSO\Buck', 'sysadmin'; GO
Restart/Start SQL Server Agent, back in the SQL Server Configuration Manager.

Check client connection to SQL Server 2008 Express [duplicate]

I just installed SQL Server 2008 Express on my Vista SP1 machine. I previously had 2005 on here and used it just fine with the old SQL Server Management Studio Express. I was able to connect with no problems to my PC-NAME\SQLEXPRESS instance (no, PC-NAME is not my computer name ;-).
I uninstalled 2005 and SQL Server Management Studio Express. I then installed SQL Server 2008 Express on my machine and elected to have it install SQL Server Management Studio Basic.
Now, when I try to connect to PC-NAME\SQLEXPRESS (with Windows Authentication, like I always did), I get the following message:
Cannot connect to PC-NAME\SQLEXPRESS.
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, Error: -1)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476
When I installed SQL Server 2008, I had it use SQLEXPRESS as the local instance name. As far as I can tell, through SQL Server Configuration Manager, SQL Server is configured to allow remote connections.
When I went to the help link it mentions, the help page suggests the following:
Make sure that the SQL Server Browser service is started on the server.
Use the SQL Server Surface Area Configuration tool to enable SQL Server to accept remote connections. For more information about the SQL Server Surface Area Configuration Tool, see Surface Area Configuration for Services and Connections.
Well, as far as I can tell, there is no SQL Server Browser service on my system (looked in MMC for one, couldn't find one).
And the SQL Server Surface Area Configuration tool doesn't exist in SQL Server 2008. So good job there with your help documentation, Microsoft ;-).
I'm at a loss for what to do right now. I had a lot of work I was hoping to get done today after upgrading to 2008 (the person I'm working with got it up and running with no problem and told me it would be easy - he's also far better with database stuff that I am). Does anyone have any idea what might be wrong? I'd really appreciate it. If I can't get this working in a few hours, I'm going back to SQL Server 2005 (if that will even work, gah...).
Edit: I have tried turning Windows Firewall off, and that did not help. Also, I noticed that I do not have a "Data" directory under my SQL Server 2008 install directory tree - could I have possibly set something up wrong when I installed it?
Please check the ServerName which you provided. It should match with the below shown Name in the UserName textbox, and that name should followed with \SQLEXPRESS:
Start your Local SQL Server Service
Start SQL Config Manager: Click Start -> Microsoft SQL Server 2008 R2 -> SQL Server
Configuration Manager
Start SQL Services: Set the SQL Server (SQLEXPRESS) and SQL Server Browser services to automatic
start mode. Right-click each service -> Properties -> Go into the Service Tab
This will ensure they start up again if you restart your computer. Please check to ensure the state is "Running" for both services.
Login and authenticate with your Local SQL Server
Now open up SQL Server Management Studio and click "Connect to Object
Explorer" and select Server Name:
[Your PC name]\SQLEXPRESS
Example: 8540P-KL\SQLEXPRESS or (localhost)\SQLEXPRESS
To find your PC name: Right click My Computer -> Properties ->
Computer Name tab
Alternative: Login using windows authentication: Using the user name [Your
Domain]/[Your User Name]
Setup User Account
Create a new Login acct: In SQL Mgmt Studio -> Expand your local Server -> Security -> Right
click on Logins -> New Login
Set Password settings on New User Account: Uncheck Enforce password policy, password expiration and user must
change pw(Since this is local) Default database -> Your Database
Grant roles to New User Account: User Mapping Page -> Map to your db and grant db_owner role Status
Page -> Grant Permission to connect and Enable Login
Setup Access Permissions/Settings for User
Enable all auth modes: Right click your Local Server -> Properties -> Security Tab -> Enable
SQL Server and Windows Authentication Mode
Enable TCP/IP: Open SQL Server Configuration Manager -> SQL Server Network
Configuration -> Protocols for SQLEXPRESS -> Enable TCP/IP
Restart SQL Server Service: You will have to restart the SQL Server(SQLEXPRESS) after enabling TCP/IP
Database Properties File for Spring Project
database.url=jdbc:jtds:sqlserver://[local PC Computer
name];instance=SQLEXPRESS;DatabaseName=[db name];
database.username=[Your user name] database.password=[Your password]
database.driverClassName=net.sourceforge.jtds.jdbc.Driver
If you want to view larger screen shots and better formatting of the answer with more details please view the blog article below:
Setting up a Local Instance of SQL Server 2008 Blog Post:
I used (LocalDB)\MSSQLLocalDB as the server name, I was then able to see all the local databases.
Haha, oh boy, I figured it out. Somehow, someway, I did not install the Database Engine when I installed SQL Server 2008. I have no idea how I missed that, but that's what happened.
I know this question is old, but in case it helps anyone make sure the SQL Server Browser is running in the Services MSC. I installed SQL Server Express 2008 R2 and the SQL Server Browser Service was set to Disabled.
Start->Run->Services.msc
Find "SQL Server Browser"->Right Click->Properties
Set Startup Type to Automatic->Click Apply
Retry your connection.
I've just solved a problem related to this which may help other people.
Initially when loading up MSSMSE it had the server as PC_NAME\SQLEXPRESS and when I tried to connect it gave me Error: 26 - Error Locating Server/Instance Specified, so I went into SQL Server Configuration Manager to check if my SQL Server Browser and SQL Server services were running and set to automatic, only to find that instead of saying SQL Server (SQLEXPRESS) it says SQL Server(MSSQLSERVER).
I then tried connecting to PC-NAME\MSSQLSERVER and this time got SQL Network Interfaces, error: 25 - Connection string is not valid) (MicrosoftSQL Server, Error: 87) The parameter is incorrect so I googled this error and found that somebody had suggested that instead of using PC-NAME\MSSQLSERVER just use PC-NAME as the Server Name at the server connection interface, and this seems to work.
There's a link here http://learningsqlserver.wordpress.com/2011/01/21/what-version-of-sql-server-do-i-have/ which explains that MSSQLSERVER is the default instance and can be connected to by using just your hostname.
I think this may have arisen because I've had SQL Server 2008 installed at some point in the past.
Under Configuration Manager and Network Configuration and Protocols for your instance is TCP/IP Enabled? That could be the problem.
var.connectionstring = "server=localhost; database=dbname; integrated security=yes"
or
var.connectionstring = "server=localhost; database=dbname; login=yourlogin; pwd=yourpass"
For me, I was only able to get it to work by using "." in the server name field; was banging away for awhile trying different combos of the user name and server name. Note that during install of the server (ie this file: SQLEXPR_x64_ENU.exe) i checked default instance which defaults the name to MSSQLSERVER; the above high voted answers might be best used for separate named (ie when you need more than 1) server instances.
both of these videos helped me out:
use dot for server name: https://www.youtube.com/watch?v=DLrxFXXeLFk
general setup: https://www.youtube.com/watch?v=vng0P8Gfx2g
One of the first things that you should check is that the SQL Server (MSSQLSERVER) is started. You can go to the Services Console (services.msc) and look for SQL Server (MSSQLSERVER) to see that it is started. If not, then start the service.
You could also do this through an elevated command prompt by typing net start mssqlserver.
For me it was a windows firewall issue. Allow incoming connections. Opening port didn't work but allow programs did.
Link
Link2

SQL Server 2008 R2 can't connect to local database in Management Studio

I am using SQL Server 2008 R2 Express.
I first installed SQL Server 2008 R2 Express Management Studio and then I installed SQL Server 2008 R2 Express. I have the instance SQLEXPRESS running and it is set to automatic.
I am trying to connect to it locally using Windows authentication - server name is set to local and the username is grayed out and set to my profile username.
When I try to connect I get the following error:
Have I installed the wrong SQL Server Management Studio?
If your instance is called SQLEXPRESS, then you need to use .\SQLEXPRESS or (local)\SQLEXPRESS or yourMachineName\SQLEXPRESS as your server name - if you have a named instance, you need to specify that name of the instance in your server name.
Your "SQL Server Browser" service has to be started too.
Browse to Computer Management > Services.
Find find "SQL Server Browser"
set it to Automatic
and also Manually start it (2)
Hope it helps.
Follow these steps to connect with SQL Server 2008 r2 (windows authentication)
Step 1: Goto Control Panel --> Administrator Tools --> Services
select SQL SERVER (MSSQLSERVER) and double click on it
Step 2:
Click on start Service
Step 3:
Now login to SQL server with Windows authentication
and use user name : (local)
Enjoy ...
I also received this error when the service stopped. Here's another path to start your service...
Search for "Services" in you start menu like so and click on it:
Find the service for the instance you need started and select it
(shown below)
Click start (shown below)
Note: As Kenan stated, if your services Startup Type is not set to Automatic, then you probably want to double click on the service and set it to Automatic.
I know, this problem can be faced by so many people and many of them have uninstalled and re-installed the sql server for resolving this issue.
In my observation the problem of not connecting the database service locally is just because of your network connection you are using, in most of the cases these problems will come when you are using wi-fi network.
Solution is, if you are using wi-fi then just right click on status of the network and get the ip details and enter the same ip in sql server name,
it will work.
Regards
Vishwajeet
I have the same error but with different case. Let me quote the solution from here:
Luckly I also have the same set up on my desktop. I have installed
first default instance and then Sql Express. Everything is fine for
me for several days. Then I tried connecting the way you trying, i.e
with MachineName\MsSqlServer to default instance and I got exctaly the
same error.
So the solution is when you trying to connect to default instance you
don't need to provide instance name.(well this is something puzzled
me, why it is failing when we are giving instance name when it is a
default instance? Is it some bug, don't know)
Just try with - PC-NAME and everything will be fine. PC-NAME is the
MSSQLServer instance.
Edit : Well after reading your question again I realized that you are
not aware of the fact that MSSQLSERVER is the default instance of Sql
Server. And for connecting to default instance (MSSQLSERVER) you
don't need to provide the instance name in connection string. The
"MachineName" is itself means "MachineName\MSSQLSERVER".
Lots of the above helped for me, plus the accepted answer, but since I was on an EC2 instance, I had no idea what my instance name was. Finally, I opened SQLServer Configuration Manager and in the Name column, use whatever is there as your connection server, so in my case, .\EC2SQLEXPRESS and worked great!
Okay so there might be various reasons behind Sql Server Management Studio's(SSMS) above behaviour:
1.It seems that if our SSMS hasn't been opened for quite some while, the OS puts it to sleep.The solution is to manually activate our SQL server as shown below:
Go to Computer Management-->Services and Applications-->Services. As you see that the status of this service is currently blank which means that it has stopped.
Double click the SQL Server option and a wizard box will popup as shown below.Set the startup type to "Automatic" and click on the start button which will start our SQL service.
Now check the status of your SQL Server. It will display as "Running".
Also you need to check that other associated services which are also required by our SQL Server to fully function are also up and running such as SQL Server Browser,SQL Server Agent,etc.
2.The second reason could be due to incorrect credentials entered.So enter in the correct credentials.
3.If you happen to forget your credentials then follow the below steps:
First what you could do is sign in using "Windows Authentication" instead of "SQL Server Authentication".This will work only if you are logged in as administrator.
Second case what if you forget your local server name? No issues simply use "." instead of your server name and it should work.
NOTE: This will only work for local server and not for remote server.To connect to a remote server you need to have an I.P. address of your remote server.
I had this problem. My solution is: change same password of other in windowns. Restart Service (check logon in tab Service SQL).

Error connecting to SQL Server using SQL Server Management Studio

I've been trying to connect to SQL Server using SQL Server Management Studio to no avail.
This is what the error says:
Cannot connect to .\HAMED.
ADDITIONAL INFORMATION:
Login failed for user 'HAMED'. (Microsoft SQL Server, Error: 18456)
I have an instance of SQL Server by the name of Hamed which is run in Network Sevice mode. I'm using Windows 7.
I'm guessing you didn't grant yourself SQL admin during the install, but are you sure the DB instance is "HAMED"? That sounds like the machine name. Try connecting to .\sqlexpress
Do you remember the SA password? If so, you can add yourself by logging in with that account. Otherwise, you'll have to jump through some hoops and loops to get yourself added.
If you forgot to add yourself to the SQL admin group, read this article:
http://blogs.ameriteach.com/chris-randall/2009/12/11/sql-server-2008-forgot-to-add-an-administrator-account.html
It looks like you're trying to use "SQL Server Authentication" in the login dialog in SSMS, but the user that you're trying to use is a Windows user/administrator? If so, the fix should be as simple as choosing "Windows Authentication" in the drop-down.
UPDATE: looks like I jumped the gun - this sql server forum thread lists lots of possible issues, including permissions issues, orphan users, etc.
sa... the answer was sa.
I had set the administrative password but didn't know the username to go with it. Very nube, I know, you can hit me with it later.
When I installed SQL it asked me to set administrative password - right now SSMS can login.
Under users I see 1\cory (1 is my machine name - I'm trying a numbering scheme). But if I type that in it fails with the error. SQL says "no, that's an NT login, I can't use those".
Under the users list SQL does in fact show the user as Windows authentication but as I said - for some reason I can't connect using Windows authentication. The connection times out.
I'll just add a direct user name here.
All this is to do the MSVA courses for SQL certification. First exam: get sql SSMS to work.

Resources