February 15, 2007 at 3:21 am
Hi,
I need a script which added login and users automatically in databases server.
February 15, 2007 at 4:15 am
check if u can use the script below.
http://www.sqlservercentral.com/scripts/viewscript.asp?scriptid=1598
Cheers,
Sugeshkumar Rajendran
SQL Server MVP
http://sugeshkr.blogspot.com
February 16, 2007 at 2:11 am
I need something like this
check syslogins if they exists
if not create
for each database execute sp_adduser
February 16, 2007 at 5:04 am
DECLARE @command1 nvarchar(2000)
-- Set parameter values
Select @command1 = 'if not exists (select * from master.dbo.syslogins where loginname = N''yourdomain\youruser'')
exec sp_grantlogin N''yourdomain\youruser''
exec sp_defaultdb N''yourdomain\youruser'', N''XLANG''
exec sp_defaultlanguage N''yourdomain\youruser'', N''us_english''
GO
if not exists (select * from dbo.sysusers where name = N''yourdomain\youruser'' and uid < 16382)
EXEC sp_grantdbaccess N''yourdomain\youruser'', N''yourdomain\youruser''
GO '
--print @command1
-- use the undocumented sp_msforeachdb
EXEC @rc = [master].[dbo].[sp_MSforeachdb] @command1
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply