{"id":143,"date":"2011-08-08T09:15:13","date_gmt":"2011-08-08T03:45:13","guid":{"rendered":"https:\/\/blog.binarybits.net\/?p=143"},"modified":"2011-08-08T09:15:13","modified_gmt":"2011-08-08T03:45:13","slug":"resetting-an-sql-server-account-when-there-is-no-access-through-sql-server-authentication","status":"publish","type":"post","link":"https:\/\/blog.binarybits.net\/resetting-an-sql-server-account-when-there-is-no-access-through-sql-server-authentication\/","title":{"rendered":"Resetting an SQL Server account when there is no access through SQL Server Authentication"},"content":{"rendered":"
Scenario:<\/strong><\/p>\n Microsoft has removed the functionality of automatically adding the local windows system admin to SQL 2008 Users. The following solutions are workaround to get inside the SQL server by adding a user to SQL Users Table.<\/p>\n Note: Since this involves SQLCMD and starting, stopping of SQL Instance the logged in user should be an administrator of that server where the SQL Server is running and both solutions should be run under an elevated command prompt.<\/p>\n Solution 1 : (Little difficult Solution. Check Solution 2 for automated script by Microsoft)<\/strong><\/p>\n Open command prompt.<\/p>\n sqlservr -m”SQLCMD”<\/p><\/blockquote>\n CREATE LOGIN [testAdmin] WITH PASSWORD=N’test@1234′, DEFAULT_DATABASE=[master]; Note: If you do not have SQL authentication enabled then you can try adding your windows user and replace setp-6 with below queries. Here <<DOMAINUSERNAME>> is placeholder for your user name<\/p>\n create login [<<DOMAINUSERNAME>>] from windows; Source: http:\/\/beyondrelational.com\/blogs\/chintak\/archive\/2010\/07\/20\/sql-2008-r2-new-installation-and-login-password-unknown.aspx<\/a><\/p>\n Solution 2 : (Easy Solution)<\/strong><\/p>\n\n
\n
\n
\nEXEC sys.sp_addsrvrolemember @loginame = N’testAdmin’, @rolename = N’sysadmin’;
\nGO<\/p><\/blockquote>\n\n
\nEXEC sys.sp_addsrvrolemember @loginame = N'<<DOMAINUSERNAME>>’, @rolename = N’sysadmin’;
\nGO;<\/p><\/blockquote>\n