Add account to SQL Server from command

If you in case forget add any account to sql server, or forget all the account to login to the sql server. what should I do? Reinstall the SQL Server instance? Here is an simpler solution from others which is really good.

Step 1. Stop all the SQL server instance and related services

Step 2. Run sqlservr -m from command. This command will start the sql server in single-user mode. sqlservr normally stored in Binn folder in SQL Server.

Step 3. Open a new command, Run SQLCMD -S -E ,type the commands next:



EXEC sp_addsrvrolemember @loginame=’\’, @rolename=’sysadmin’



Last Step: Restart the Sql Server instance. the command is NET Start MSSQLSERVER


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s