I have the following SQL code, but I want to check to see if the SQL user is already created before trying to run the create user code so as to avoid errors. Could someone tell me how I can do an if statement in SQL for this?
Thanks in advance
Simon
VB.NET:
EXECUTE sp_detach_db @dbname = N'MRCS',
@skipchecks = N'TRUE'
GO
EXECUTE sp_attach_single_file_db @dbname = N'MRCS', @physname = N'C:\Program Files\Ticodi\MRCS\Database\MRCS_Data.mdf'
GO
[COLOR="Red"]If user does not exist then do this code[/COLOR]
EXECUTE execute sp_addlogin @loginame = N'MRCSAdmin',
@passwd = 'dragnet',
@defdb = N'MRCS',
@deflanguage = N'us_english'
GO
[COLOR="red"]Endif statement[/COLOR]
Thanks in advance
Simon