Hi allI've got some code that creates a new user onn a SQL Server 2008 R2 box.The code is:-exec Reports.dbo.create_new_user @usernameThis is the Alter procedure statement :-ALTER PROCEDURE [dbo].[Create_New_User] @username sysnameASBEGIN SET NOCOUNT ON DECLARE @SQL NVARCHAR(4000); SET @SQL = 'CREATE LOGIN [' + @username + '] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[British]' EXECUTE(@SQL); END;
Unfortunately, it doesn't map the new user to any databases so I can't use any further code to assign rtoles that user in the relevant database.When I try to execute the following code:-[code]exec [Lumia].dbo.drop_user_role @role_name='db_accessadmin', @username=@user_name
I get an error stating that the user or role does not exist in this database.I've checked the properties of the new user and there are no databases ticked under user mapping.I can't add any new roles to assing new users to as 2008R2 doesn't support user-defined roles.Anyone any ideas of a way around this?