if not exists (select * from master..syslogins where name = 'uid')
BEGIN
declare @logindb nvarchar(132), @loginlang nvarchar(132) select @logindb = 'dclms', @loginlang = 'us_english'
if @logindb is null or not exists (select * from master..sysdatabases where name = @logindb)
select @logindb = 'master'
if @loginlang is null or (not exists (select * from master..syslanguages where name = @loginlang) and @loginlang <> 'us_english')
select @loginlang = @@language
exec sp_addlogin 'uid', 'pwd', @logindb, @loginlang
END;
exec sp_addsrvrolemember 'uid', sysadmin;
if not exists (select * from sysusers where name = 'uid' and uid < 16382)
EXEC sp_grantdbaccess 'uid', 'uid'