Database

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:

CREATE LOGIN [\] FROM WINDOWS

GO

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

GO

SHUTDOWN

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

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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