Create a login using command prompt (CMD)

Scenario

You have got the SQL database engine installed but no SSMS installed on it. In this scenario how you will connect to the target database engine and create a login to allow a connection or how will you connect to SQL database engine without SSMS.

Solution

Create a login using the command prompt.

The below steps are to create a login using Command Prompt.

Open CMD and type the below command to connect to the Database engine

then hit enter

if you see “1>” in the next line, then you are now connected to the SQL engine.

Now type the below command to create the login and give a permission

hit enter.
Then type the below command to add the “SYSADMIN” permission.

then type

and hit enter.

Screenshot for your reference:

Login creation using CMD
Login creation using CMD

Now this created a login for you and you can connect to the Database engine from another server

Now verify if the login is created

Open CMD and type the below command to connect to the Database engine

Now type below command to see if your login got created.

You will get the list of logins present on this SQL instance as shown in the below screenshot.

SQL login verification using CMD
SQL login verification using CMD

Comments

  • In mentioned scenario how you weil able to connect through sqlcmd prompt if you don’t hat access target server???
    If you are able to connect through sql cmd prompt which means you has access to connect target server so obviously you will able to connect sql through ssms.

Leave a Reply

Your email address will not be published. Required fields are marked *