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';
goBut no luck.
MSG 15151 level 16 State 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';
GOBut 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.