Is it possible to use sp_addrolemember on a SQL Server database without Management Studio? Only using sqlcmd

 SQL role membership

I’m trying to avoid installing Management Studio on multiple servers.

Is it possible to add Sp_addrolemember to a database only using sqlcmd?

I tried:

sqlcmd -S .\SQLEXPRESS -E
USE [DBName]
EXEC sp_addrolemember 'DBName', 'db_owner';
go

But no luck.

MSG 15151 level 16 State 1

1

1 Answer

Yes, it's possible. But you used the wrong syntax. Once connected to SQLCMD, the correct Syntax would be:

USE [DBName]
EXEC sp_addrolemember 'db_owner', 'username';
GO

But you don't need to install Management Studio on the server to access the database, you can access the servers remotely from the Management Studio you have installed on your desktop.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like