I need to check if a specific user already exists on the SQL Server, and if it doesn't, then I need to add it.
I have found the following code to actually add the user to the database, but I want to wrap this in an IF statement (somehow) to check if the user exists first.
CREATE LOGIN [myUsername] WITH PASSWORD=N'myPassword',
DEFAULT_LANGUAGE=[us_english],
CHECK_EXPIRATION=OFF,
CHECK_POLICY=OFF
GO
I understand that I need to interrogate a system database, but not sure where to start!