Showing posts with label sp_addlogin. Show all posts
Showing posts with label sp_addlogin. Show all posts

Thursday, March 8, 2012

Adding numerous login via script

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.

Adding NT login using T-SQL

Is it possible to create new login (NT or Windows) using T-SQL? sp_addlogin
doesn't seem to have this capability.
Thank you in advance for your help!Use sp_grantlogin for that.
As of 2005, you use CREATE LOGIN for both types of logins.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Leon Shargorodsky" <LeonShargorodsky@.discussions.microsoft.com> wrote in me
ssage
news:1C6B2795-8C35-45B2-B584-3B615CE505D9@.microsoft.com...
> Is it possible to create new login (NT or Windows) using T-SQL? sp_addlogi
n
> doesn't seem to have this capability.
> Thank you in advance for your help!

Adding NT login using T-SQL

Is it possible to create new login (NT or Windows) using T-SQL? sp_addlogin
doesn't seem to have this capability.
Thank you in advance for your help!Use sp_grantlogin for that.
As of 2005, you use CREATE LOGIN for both types of logins.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Leon Shargorodsky" <LeonShargorodsky@.discussions.microsoft.com> wrote in message
news:1C6B2795-8C35-45B2-B584-3B615CE505D9@.microsoft.com...
> Is it possible to create new login (NT or Windows) using T-SQL? sp_addlogin
> doesn't seem to have this capability.
> Thank you in advance for your help!

Saturday, February 25, 2012

Adding login to SQL SERVER

I am trying to add a new login using sp_addlogin but I
get message:
'User X does not have permission to perform this action'.
I executed
sp_addsrvrolemember 'User X', 'sysadmin' and
sp_grantlogin 'domain\user X '
but when I login as an user X IS_SRVROLEMEMBER tells me
that 'Current user's login is NOT a member of the
sysadmin role'.
I executed sp_helpsrvrolemember and I see that
domain/user X is a member of sysadmin but is not a member
of securityadmin.What do you get when you run the following command:
SELECT SUSER_SNAME()?
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
What hardware is your SQL Server running on?
http://vyaskn.tripod.com/poll.htm
"Alex" <anonymous@.discussions.microsoft.com> wrote in message
news:082801c3b902$833d6d60$a001280a@.phx.gbl...
I am trying to add a new login using sp_addlogin but I
get message:
'User X does not have permission to perform this action'.
I executed
sp_addsrvrolemember 'User X', 'sysadmin' and
sp_grantlogin 'domain\user X '
but when I login as an user X IS_SRVROLEMEMBER tells me
that 'Current user's login is NOT a member of the
sysadmin role'.
I executed sp_helpsrvrolemember and I see that
domain/user X is a member of sysadmin but is not a member
of securityadmin.