Is It Possible to Use Sp_Addrolemember on a Sql Server Database Without Management Studio? Only Using Sqlcmd

Is It Possible to Use Sp_Addrolemember on a Sql Server Database Without Management Studio? Only Using Sqlcmd

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

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

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.