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.
Create a login using the command prompt.
Open CMD and type the below command to connect to the Database engine
1 |
sqlcmd -S FDQN\INSTANCE,port |
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
1 |
CREATE LOGIN [you_login_name] FROM WINDOWS WITH DEFAULT_DATABASE=[master] |
hit enter.
Then type the below command to add the “SYSADMIN” permission.
1 |
ALTER SERVER ROLE [SYSADMIN] ADD MEMBER [your_login_name] |
then type
1 |
GO |
and hit enter.
Screenshot for your reference:
Now this created a login for you and you can connect to the Database engine from another server
Open CMD and type the below command to connect to the Database engine
1 |
sqlcmd -S FDQN\INSTANCE,port |
Now type below command to see if your login got created.
1 |
SELECT name from sys.syslogins |
You will get the list of logins present on this SQL instance as shown in the below screenshot.
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.
Thanks Siddhartha for your comment. My intention was to create a login using Command Prompt. I have updated my context.
[…] Create a login using command prompt (CMD) • Our Tech Ideas […]
[…] Create a login using command prompt (CMD) • Our Tech Ideas […]