Quantcast
Channel: SQL Server Manageability forum
Viewing all articles
Browse latest Browse all 1519

Create login and assign sysadmin

$
0
0

Trying to create an sql windows authentication login and assign sysadmin privelleges via command line . The account is already created on the server , i can get the  account created in sql ok but when i try and give it sysadmin rights then i get "username xxx is not a valid login or you do not have permission"

DECLARE @sql nvarchar(1000)

SET @SQL = 'Create login [' ++ @@servername + '\username] FROM WINDOWS

EXEC sp_executeSQL @SQL

EXEC sp_addsrvrolermember 'username', 'sysadmin'

I have tried this when logged in as sa also, any ideas ? 


Viewing all articles
Browse latest Browse all 1519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>