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 ?