Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
raghuveer125
Constraint Violating Yak Guru
285 Posts |
Posted - 2012-10-12 : 16:30:52
|
Hi I am getting half output if I have more than 3 logins in tableSelect 'If not exists (select * from sysusers a inner join master..syslogins b on (a.sid = b.sid) and a.name = ' + '''' + a.name + '''' + ')begin' +-- char(13) + char(9) + 'if exists(select * from sysusers where name = ' + '''' + a.name + '''' + ') begin exec sp_change_users_login ' + '''' +'update_one' + '''' + ',' + '''' + a.name + '''' + ',' + '''' + b.name + '''' + --char(13) + char(9) + 'endelse begin exec sp_grantdbaccess ' + '''' + b.name + '''' + ',' + '''' + a.name + '''' +-- char(13) + char(9) + 'end' +-- char(13) + 'end ' COLLATE Latin1_General_CI_AS --needed for case insenstive 2000 servers. Remove for 7.0 serversfrom sysusers aleft outer join master..syslogins bon a.sid = b.sidwhere (a.issqluser = 1 or a.isntuser = 1 or a.isntgroup = 1)and a.name not in('guest','dbo') and a.name not like 'repl%'group by a.name,b.namehaving b.name is not nullorder by 1 descIn Love... With Me! |
|
|
|
|