sql server 2012: cannot alter the login sa - ssms

I'm trying to create a database on my local machine using SSMS version 11.0.2100.60. I've run the application as administrator, logged in using Windows authentication, and I've added MYDOMAIN\my-username to the Logins. However if I try to create a db with this login I get the message
CREATE DATABASE permission denied in database 'master'.
(Microsoft SQL Server, Error: 262)
If I try to add the privelage dbcreator to my user, I get the following error.
User does not have permission to perform this action.
(Microsoft SQL Server, Error: 15247)
I can't log in as sa as I don't know/remember the password (is there a preset default?), and if I try to change the password I get the message:
Cannot alter the login 'sa', because it does not exist or you do not have permission.
(Microsoft SQL Server, Error: 15151)
Finally I note that the account 'sa' is disabled, and if I try to enable it I get the same error as before. Is there any way around this or do I need to re-install?
Version info:
Microsoft SQL Server Management Studio 11.0.2100.60
Microsoft Analysis Services Client Tools 11.0.2100.60
Microsoft Data Access Components (MDAC) 6.2.9200.16384
Microsoft MSXML 3.0 4.0 6.0
Microsoft Internet Explorer 9.10.9200.16635
Microsoft .NET Framework 4.0.30319.18051
Operating System 6.2.9200

I found the answer here:
In order to start SQL Server in single-user mode, you can add the
parameter “-m” at the command line. You can also use the SQL Server
Configuration Manager tool, which provides proper controls for the
file access and other privileges. To use the Configuration Manager
tool to recover your system, use the following steps:
Open the Configuration Manager tool from the "SQL Server 2005| Configuration" menu
Stop the SQL Server Instance you need to recover
Navigate to the “Advanced” tab, 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

A little more specific :
Open Sql Configuration Manager.
Select SQL Server Services.
On the right hand side, select the instance.
Right click on it and open properties.
In the advanced tab attach ";-m" at the end of the Startup Parameters field.
Apply and restart the service.
Now you have privilege to enable "sa" user and modify its password.
once done, remove ";-m" and restart the service.
You are good to go.

I'd like to point out an alternative answer laid out on DBA SE. Download PSExec onto the box that is having the problem and follow the instructions laid out in this blog post to effortlessly change admin settings using the NT Authority\System account.
./psexec -s -i "C:\...\Ssms.exe"
Wanted to share this solution as it solved my problem!

Related

How to fix TF246017 The Team foundation server could not connect to database

I'm getting nothing but this error TF246017 I'm not able to access TFS as admin or domain user
While accessing administration console, showing the error TF246017
Domain users getting TF31001 where the server returns TF246017
TFS was working fine with SQL Server 2008. And now we have also installed SQL server 2012 in the same machine.( I believe it doesn't connected anyway to tfs server)
But, even after uninstalling SQL 2012, it displays the same error
In application tier/ database tier, getting error as Error retrieving value.
Unable to access http://xxxxxxx:8080/tfs displays same error TF246017
And also, im unable to locate the sql express database to take the backup.
How to resolve this issue?
Note : I'm using TFS 2012 and VS2010
Login to windows server using the same windows credential user you used during SQL Server installation.
Verify or add the new windows user credential (assuming you are using different user credential to connect to TFS) to be part of sysadmin user group in SQL Server or ask your SQL Server DBA to add the user to sysadmin group.
Note: This is required because for every new TFS Team project created, TFS presents 2 option empty database or new database. To create new database the TFS admin user have to be part of SQL server sysadmin group
If TFS 2012 was installed using the same windows credential, open the TFS Admin console and add or verify the user is listed in "administration Console Users" list.
If TFS Admin console reads "You do not have permission or not administrator" or something along this line, then you need to log out and log back using the correct windows credential used for installation or use one of the TFS admin user and then add the new user credential.
Recommendation: To avoid confusion I would recommend use the same user credential for SQL Server and TFS server. Ex: "domainname/tfs" is local admin to the server, sysadmin in SQL Server DB and also admin user to TFS server.
To make like simple start of by, adding the windows user (intended to use as TFS admin) as windows administration group. Then logout and log back using the TFS admin user to install SQL Server and TFS server.
I had a similar issue branch code in my version of TFS (Azure DevOps Premise). I tracked my issue down by looking at the event viewer on the local TFS server and found that I was that I was getting the following SQL error:
DESCRIPTION: SQL Server Assertion: File: , line=951 Failed Assertion =
'IS_OFF (BUF_MINLOGGED, m_buf->bstat) || pageModifyType !=
PageModifyType_Contents || GetPagePtr ()->IsTextPage ()'. This error
may be timing-related. If the error persists after rerunning the
statement, use DBCC CHECKDB to check the database for structural
integrity, or restart the server to ensure in-memory data structures
are not corrupted.
I found the first item in the following answer solved my issue.
I simply switched my main TFS database containing my collection to FULL recovery mode and I was immediately able to proceed with my previously erroring task.
Connect to your SQL instance via SQL Server Management Studio and check if any of the TFS databases are in a "Recovery Pending" state. If so, restart your SQL instance and the state should return to normal. Worked for me!
Just find out the Team foundation application under application pool. right click and go to advance setting set the identity using the credentials used for SQL Sever or TFS Admin and done ..you can now access the TFS as earlier.

FILESTREAM feature is disabled

I have a database set up with FILESTREAM enabled on it (if you go to Properties\Advanced on the instance, it shows that FILESTREAM is enabled). I also ran the sp_configure script on it after doing this to enable the access (to make sure it was enabled). But...as soon as I try to alter the database and add the filegroup to it, it says that the feature is disabled.
I have it enabled on other instances on the same computer, and those work fine. It is only this one that is not working. I have not been able to find any good suggestions as to why it is not working.
It is a SQL 2008 R2 instance.
I was unable to script this, (using the link provided by user1977061), as the MSSQLService requires a restart afterwards to apply the change. Even after doing this it didn't work, and instead I had to manually configure FILESTREAM usage via:
SqlServer Configuration Manager
Sql SQL Server Services
SQL Server(MSSQLSERVER) [Properties]
FILESTREAM tab - enable the first 2, and optionally 3rd check box.
Look at the SQLServer properties > Advanced > Running Values value for "Filestream Access Level" to ensure that the FILESTREAM is actually enabled if in doubt.
Was FILESTREAM enabled on the instance level, though?
In Microsoft Sql Server Management Studio, right-click the server and select Properties. Then on the Advanced page, ensure that FILESTREAM Access Level is not set to Disabled (Which I believe is default):
Changing the FILESTREAM settings through SQL Server Management Studio -> Properties -> Advanced had no effect for me, and SQL Server Configuration Manager kept giving me an error when I enabled FILESTREAM there:
There was an unknown error applying the FILESTREAM settings.
Check the parameters are valid. (0x80041008)
Digging around on the internet led me here as well as to this page: https://social.msdn.microsoft.com/forums/sqlserver/en-US/d8060fdd-4583-4bf7-bdcf-4fd053d5d2c0/unknown-error-applying-the-filestream-settings
Fortunately one of the suggestions there was the solution. Connect to the server with SQL Server Management Studio and run this script:
sp_configure 'filestream access level', 2
reconfigure with override
Note: This was for 64-bit SQL Server 2012
For me this worked out:
forget about Microsoft SQL Server Management Studio to solve this bug
find SQLServerManager**.msc in folder C:\Windows\SysWOW64 and open it
enable filestream as in the picture, by clicking on properties
Database import should work then!
I've done this a thousand times and always follow the steps as Mojo outlines above. However I found that on one computer I couldn't get this to work unless I changed SQL Server Service from running as NT Service to running under a local account. I even reinstalled SQL Server, no luck.
I did as follows:
Click start
Type 'compmgmt.msc'
Expand 'Services and Applications'
Sql Server Configuration
Right Click on 'SQL Server (MSSQLSERVER)' and choose 'Properties'
On the Log On tab, change the user to a local account
Maybe one day this will save someone from banging their head on their desk until their eyeballs pop-out.
If you still are having problems with this i suggest you checkout this link!
I had the same problem in which only one instance didn't activate filestream properly. The solution seems to be to use the SQL Server Configuration Manager and enable it from there.
In addition to the other answers: the account that is used by the sql server service must be a member of the Administrators group.
Symptom: the "Configured value" in the server properties does show "enabled", but the "Running value" stays at "disabled".
I got this working by enabling filestream not in SQL Management Studio but in SQL Configuration Manager. See https://learn.microsoft.com/en-us/sql/relational-databases/blob/enable-and-configure-filestream?view=sql-server-2017.
On the Start menu, point to All Programs, point to SQL Server, point to Configuration Tools, and then click SQL Server Configuration Manager.
In the list of services, right-click SQL Server Services, and then click Open.
In the SQL Server Configuration Manager snap-in, locate the instance of SQL Server on which you want to enable FILESTREAM.
Right-click the instance, and then click Properties.
In the SQL Server Properties dialog box, click the FILESTREAM tab.
Select the Enable FILESTREAM for Transact-SQL access check box.
If you want to read and write FILESTREAM data from Windows, click Enable FILESTREAM for file I/O streaming access. Enter the name of the Windows share in the Windows Share Name box.
If remote clients must access the FILESTREAM data that is stored on this share, select Allow remote clients to have streaming access to FILESTREAM data.
Click Apply.
In SQL Server Management Studio, click New Query to display the Query Editor.
In Query Editor, enter the following Transact-SQL code:
SQL
Copy
EXEC sp_configure filestream_access_level, 2
RECONFIGURE
Click Execute.
Restart the SQL Server service.
For me only the combination of SchmitzIT and Mojo suggestions made it work
I also stumbled into this problem and by trial and error i found out that the solution was to change the account under which Sql Server runs so from SS Configuration manager i located the sql server instante, right clicked "Properties" and on the "LOg On" tab i changed Logon as "This account" to "Bulil-in account", where i choose "Local system".
After a service restart all went fine.

Microsoft SQL Server Management Studio trouble with permissions

Please find all the files I'm refering to at this link:
http://whyisthisinmyfood.com/sql/
I have installed a new copy of "SQL Server 2008 R2 Management Studio Express (x86)" on two Windows 7 computers. The SAME install file for both computers. Installed the same way. (as far as I know, I chose the same options)
One at home and one at work.
The one at home seems to work perfectly I "Execute" this file (ITD132-Inventory Initial with data.sql) and it works fine. When I "Execute" it at work I get:
Msg 262, Level 14, State 1, Line 1
CREATE DATABASE permission denied in database 'master'.
..and a bunch of stuff after that which is caused because the database was not created in the first place.
I have compared the permissions on both computers.
see these files:
home computer : non-networked.jpg
work computer: work-networked.jpg
I read in one post that to create new Logins one must be logged in as the Administrator. I log into the Server Managment studio with my windows credentials and I am the Local Admin for my work computer and I have not been able to find any other place to log in as an administrator for this SQL Server Management Studio (so clearly I'm not sure whats meant by that)
At this point I think my problem is that I need to create a user who is not just the "BUILTIN\User" (because this login does not have permissions) with permissions.
But I have no idea how to login as an administrator to create this user role.
Please forgive me if these are obvious answers as I am just starting with this MS Management studio and am not very familiar with T-SQL.
Thanks,
Diana
If you install SQL Server, you get asked during installation process which user or user group should have the Admin-Privileges. If your computer is part of a domain and you login locally, things might get complicated.
The easiest (but not safest way) to login as a "superuser" if to enable the "sa" user.
this is one user that logs on with a password (not integrated logon) and has all the juice to run every script possible :-) By default it's disabled - googling I found a easy how-to enable it:
http://sudeeptaganguly.wordpress.com/2010/04/20/how-to-enable-sa-account-in-sql-server/
I think you are correct that you need to create another user with enough permission. Generally logging in with "integrated security" using your Windows credentials should have enough permissions (assuming the same user is the user that installed SQL Server). If not, you have better luck logging in as the SQL Server user "sa" (system administrator) which should have full permission. Do you know the "sa" password?
Note: the security mode for SQL Server can be set to "Only integrated security with Windows users", "SQL Server security" or "both". The "sa" account will only work if the SQL Server security is enabled. You may be able to access these settings using your BuiltIn\User account.

Taking ownership for SQL Server Management Studio

I'm new to SQL Server 2008. I just installed SQL Server Express. I'm having trouble creating a new database, and I think I don't have permission.
I login like this, please see this screenshot:
Then I tried to create a new database and I got this:
I tried to search for some solution and this what I've got:
http://blogs.msdn.com/b/sqlexpress/archive/2010/02/23/how-to-take-ownership-of-your-local-sql-server-2008-express.aspx
But I can't download the script and the page says:
An error occurred while processing your request.
Please help. Kind regards
I resolved my problem with the following steps:
Set the instance of the SQL Service to single-user mode:
Open SQL Server Configuration Manager. Double click SQL Server Services.
Stop all SQL Server services
Right click SQL service and click Properties, in the Advanced tab, look for 'Startup Parameters'
Insert '-m;' at the beginning of the Startup Parameters value
Start the SQL service
Open SQL Server Management Studio and login with Windows authentication, you can now add user or change password of different users.
Hope this helps!
Try logging in with the sa account and grant permissions to your Windows account.
If you do not know the sa password use sqlcmd and execute the following commands:
Use Master
Go
ALTER LOGIN [sa] WITH PASSWORD=N'NewPassword'
Go
Login with the sa account and GRANT permission to the account.
USE Master;
GRANT CREATE DATABASE TO Jommel;

SQL Server 2008 Error 233

I'm creating new login in SQL Server 2008 with following sql script:
CREATE LOGIN [xyz] WITH PASSWORD='xyz',
DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english],
CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
It creates new login successfully. But when I try to login with it using SQL Server Management Studio it fails saying:
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.) (Microsoft SQL Server, Error: 233)
What's wrong? How do I solve this issue?
Here is how I done it, maybe it works for you too.
login Microsoft SQL Server 2012 with windows authentication.
right-click onto the server name in Object Explorer and click Properties
In the new tab click Security
select SQL Server and Windows Authentication
Ok
Close the SQL server management studio.
start+run
write services.msc
search for SQL there and restart all services.
that works for me.
It's also possible that you're trying to use SQL Server Authentication without having enabled it. To fix this, right-click Properties on your server instance in SQL Server Management Studio, and update the security settings to include "SQL Server and Windows Authentication mode".
Looks like you're trying to connect using named pipes, but SQL Server is not listening on that protocol. See MSDN.
The two fixes MSDN suggests are:
Connect using TCP/IP, or use the SQL
Server Configuration Manager to
enable remote connections using named
pipes.
Using SQL Server Configuration
Manager on the client computer, move
TCP before named pipes in the
protocol order list.
I had a similar issue:
1. log in as the master user or windows authenticated user.
2. right click on the database --> properties --> security -->
3. change Windows Authentication mode to "SQL server and windows authentication mode" by clicking on the radio button. (if it is not)
4. restart the server
I had the same issue when i first setup SQL Server 2014 on my local machine.
In my case the solution was to set a correct defualt database.
Login with Administrator in SQL Server
Go to Securities >> Logins >> select your user name and go to properties
From Status >> uncheck user account lock check box
Change password for the user
Restart the sql server and login with your username.
I was facing the same error.
I've resolved the error by following below mentioned steps:
Disable named pipes and restart sql services.
After restart sql server I enabled names pipes and did a sql server restart again (Link for Step 1 and 2)
Connect to SQL server via studio.
Right click on SQL instance --> Properties --> Connections --> "Set the Maximum number of 5. concurrent connections to '0' ".
Save the change.
Restart the SQL server if possible. (Link for step 3 to 6)
I hope this will help someone
This is might not be a connection issue . Check your default database and if that is online . More commonly this issues seen when the default database will be offline or not exists . If your default database other than master ,better check this option.
I got a way to go around the problem.
Open one instance and login using the windows authentication
allow sql and windows auth both by right cliking on the db server.
Open second instance and login using sql authentication.
bingo the sql authenticated instance open .. :)
Actually in this way we cheat the sql authenticated instance as it tries to find an already running instance.. worked fr me.. good luck
I tried most of the solution but was not able to solve it until I found this URL which says to do the following:
Open SQL Server Management Studio and run the these queries:
sp_configure 'show advanced options', 1;
go
reconfigure
go
sp_configure 'user connections', 0
go
reconfigure
go
The reason why we got this error is that the user connections was reset to 1, so only one user was able to connect with the SQL server.
just a simple query worked for. I hope this will work for others as well.
I have not used the script style, but login through GUI I encountered the same error code. I had entered wrong user name and this is why I was getting the Sql Server, Error: 233. In order to resolve this, you should input the following information:
Server Name: MachineName\SQLEXPRESS
Authentication: SqlServer Authentication
User Name: Assigned user-name or simply sa
Password: xyzpqr
NOTE: Here I have wrote above data for demo purpose only, actual data is your machine & software's properties.
According to: https://msdn.microsoft.com/en-us/library/bb326280.aspx
Go to --> Remot setting
Go to "Remote" tab
in "Remote Assistance", Tick "Allow Remote Assistance connection to this computer", Click the "Advance" button and tick the "Allow..." and in the "Invitation" set the "30 days"
Then in the "Remote Desktop" part
Just tick "Allow remote connection to this computer"
After following the examples here and still not getting in, I found that my sa login was disabled. The following got me in:
Logged back in under windows authentication.
Expanded Security Tab
Expanded Logins Tab
Right-clicked sa and selected Properties
Went to the Status Tab
Under Login: Clicked 'Enabled' radio
Restarted Server and logged in as sa.
This assumes you have set sa password already using
ALTER LOGIN sa WITH PASSWORD = '<enterStrongPasswordHere>' ;
"A connection was successfully established with the server, but then an error occurred during the login process."
I was getting this problem from sqllocaldb when used from within Docker. The problem was the Docker image was not allocated enough memory. Increasing the memory actually fixed the problem.