Re: Adding Logins
From: BP Margolin (bpmargo@attglobal.net)
Date: 12/27/02
- Next message: Brian: "Re: Adding Logins"
- Previous message: Narayana Vyas Kondreddi: "Re: Retrieve the IP Address from a Failed Login Attempt"
- In reply to: Brian: "Adding Logins"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "BP Margolin" <bpmargo@attglobal.net> Date: Fri, 27 Dec 2002 15:22:12 -0500
Brian,
create table Brian
(
Login sysname NOT NULL primary key,
Password sysname NOT NULL
)
go
insert into Brian values ('ABC', 'XYZ')
insert into Brian values ('DEF', 'UVW')
insert into Brian values ('GHI', 'RST')
declare AddLogins INSENSITIVE cursor
FOR select Login, Password from Brian
FOR READ ONLY
declare @Login sysname, @Password sysname
open AddLogins
fetch next from AddLogins into @Login, @Password
while @@fetch_status = 0
begin
exec sp_addlogin @Login, @Password, pubs
exec pubs..sp_grantdbaccess @Login
fetch next from AddLogins into @Login, @Password
end
close AddLogins
deallocate AddLogins
use pubs
exec sp_helpuser 'ABC'
exec sp_helpuser 'DEF'
exec sp_helpuser 'GHI'
-------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.
"Brian" <bpstings6@attbi.com> wrote in message
news:008a01c2addd$fa85de10$d6f82ecf@TK2MSFTNGXA13...
> I need to add 300 new sql id to my server. I have the list
> in sql table, - 2 columns, id and pw. Versus adding eaach
> one individually, I wanted to create a script to read the
> table row by row and create the logins and be done. I
> tried using a cursor to go row by row, but had trouble.
> Any thoughts or site I might visit to get more info or
> find an already exisitng script?
>
> Thnks, Brian
- Next message: Brian: "Re: Adding Logins"
- Previous message: Narayana Vyas Kondreddi: "Re: Retrieve the IP Address from a Failed Login Attempt"
- In reply to: Brian: "Adding Logins"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|