Hi,
Can anyone point me in the direction of a script that incorporates sp_addlogin, which allows for adding 200 sql authentication logins from an excel spreadsheet, or a temporary sql table with the id info, containing the username, password, and def db?
I'm trying to avoid adding each new login one by one.
EXEC sp_addlogin 'username', 'password', 'default database'
Thanks, BPH
A simple approach is to create an expression in your Excel spreadsheet that builds the Exec sp_addlogin line. Copy the formula down to all the rows, then copy/paste the value into Query Analyzer.
If you have loaded the columns into a database table, you can execute a Select statement that builds the lines. Again, copy and paste the results and execute them. Assume you have built a table call logintemp with username, pwd, and dbase columns:
Select 'Exec sp_addlogin ''' + username + ''', ''' + pwd + ''', ''' + dbase + ''''From logintemp
You need to double the quote marks to yield a quote in the output string.
|||Thanks. I'll give that a shot.
No comments:
Post a Comment