Re: Adding Logins

From: BP Margolin (bpmargo@attglobal.net)
Date: 12/27/02


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



Relevant Pages

  • Re: Database Roles
    ... Information about "application roles" can be found in the SQL Server ... the ISP only gives one login per customer--period. ... > DefaultLogin as the user name and PowerUser, ... > Brian Lewis ...
    (microsoft.public.sqlserver.security)
  • Re: OpenSSH UseLogin parameter
    ... Brian F. Feldman wrote: ... >>I'm trying to get an openssh daemon to work with the regular login, ... > about in OpenSSH's login code, ...
    (FreeBSD-Security)
  • Re: yahoo mail
    ... "Brian BBBB" said in news:11f3a01c3f5ca$4f145f80$a001280a@phx.gbl: ... > Is anyone having problems getting into yahoo mail site ... I can login using their webmail interface, ... open their login web page but it doesn't accept your username and password? ...
    (microsoft.public.internet.mail)
  • Re: Crystal prompt for login, how to get rid of it?
    ... programmed the login info per page 359 of Brian Bischof's book. ... > I have a VB6 app to call a crystal 10 report, ...
    (microsoft.public.vb.crystal)