Hi,
I would like to create a user 'foo' in database 'mydb' if the user doesn't already exist. Currently my script looks like this:
USE [mydb]
CREATE USER [foo] FOR LOGIN [foo]
GO
However if the user already exists, this fails with an error message:
Msg 15023, Level 16, State 1, Line 2
User, group, or role 'jsrvpp' already exists in the current database.
How can I change the script so that the user is only created if they doesn't already exist?
Thanks!