Re: Adding Logins

From: Brian (bpstings6@attbi.com)
Date: 12/27/02


From: "Brian" <bpstings6@attbi.com>
Date: Fri, 27 Dec 2002 12:23:37 -0800


Thanks, I was close but couldn't figure out how my cursor
would get the values into sp_addlogin '@x' , '@y'
This line clinched it for me. (fetch next from lcur into
@id,@pass)
>-----Original Message-----
>Something like this should work :-
>
>declare @id sysname
>declare @pass sysname
>
>declare lcur cursor fast_forward for
>select [id],[password]
>from loginstable --your table name here
>
>open lcur
>
>fetch next from lcur into @id,@pass
>
>while @@fetch_status=0
>begin
>
>exec master..sp_addlogin @id,@pass
>
>fetch next from lcur into @id,@pass
>
>end
>close lcur
>deallocate lcur
>
>
>--
>HTH
>
>Jasper Smith (SQL Server MVP)
>
>I support PASS - the definitive, global
>community for SQL Server professionals -
>http://www.sqlpass.org
>
>"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: Use of user defined in SELECT clause
    ... > the UDF (open cursor, fetch next, etc). ... betaid to post to the microsoft.private.sqlserver2005.* groups. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (comp.databases.ms-sqlserver)
  • Re: Problem with simple cursor
    ... > I have a cursor here that appears to never stop running even though the ... > record set that populates it is only 22 records ... You need to move the FETCH into the loop: ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (comp.databases.ms-sqlserver)
  • Re: Mapping of "Ser Rowcount" In Informix
    ... when fetch you can always keep track of how many rows are fetched... ... This can be be done by cursor. ... like "set rowcount" in Sql Server ...
    (comp.databases.informix)