June 27, 2012 at 11:06 am
Can someone please help me in rewriting the following code using sp_addlogin and sp_adduser?
CREATE LOGIN [Domain\New_AD_group] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
go
USE Test
go
create user [Domain\New_AD_group] from login [Domain\New_AD_group]
go
EXEC sp_addrolemember N'NEW_role', N'Domain\New_AD_group'
go
June 27, 2012 at 11:21 am
I'd recommend using the code that you listed instead.
sp_addlogin is being deprecated.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
June 27, 2012 at 11:25 am
SQLRNNR (6/27/2012)
I'd recommend using the code that you listed instead.sp_addlogin is being deprecated.
I wish I could but our dev machine is SQL 2000(with Enterprise Manager) and when I run create login, it's failing.
June 27, 2012 at 11:43 am
Here's the Syntax
sp_addlogin [ @loginame = ] 'login'
[ , [ @passwd = ] 'password' ]
[ , [ @defdb = ] 'database' ]
[ , [ @deflanguage = ] 'language' ]
[ , [ @sid = ] sid ]
[ , [ @encryptopt = ] 'encryption_option' ]
You already have the following
CREATE LOGIN [Domain\New_AD_group] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
From those two sets, only two parameters match, I think you can see which they are
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
June 27, 2012 at 11:51 am
SQLRNNR (6/27/2012)
Here's the Syntax
sp_addlogin [ @loginame = ] 'login'
[ , [ @passwd = ] 'password' ]
[ , [ @defdb = ] 'database' ]
[ , [ @deflanguage = ] 'language' ]
[ , [ @sid = ] sid ]
[ , [ @encryptopt = ] 'encryption_option' ]
You already have the following
CREATE LOGIN [Domain\New_AD_group] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
From those two sets, only two parameters match, I think you can see which they are
I tried to do
EXEC sp_addlogin '[DOMAIN\New_ad_group]' -- gave me syntax error
EXEC sp_addlogin 'DOMAIN\New_ad_group' -- gave me syntax error
but when I user sp_grantlogin, it gave me no errors...here's what I ran
EXEC sp_grantlogin '[DOMAIN\New_ad_group]'
How is it possible?
June 27, 2012 at 11:54 am
What is the exact error you received?
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
June 27, 2012 at 12:28 pm
SQLRNNR (6/27/2012)
What is the exact error you received?
'Domain\New_ad_group' is not a valid name because it contains invalid characters.
June 27, 2012 at 12:50 pm
And when you use the brackets?
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
June 27, 2012 at 1:16 pm
SQLRNNR (6/27/2012)
And when you use the brackets?
Same error.
June 27, 2012 at 1:28 pm
d'oh
I missed a piece in the documentation. addlogin is for SQL logins only. Grantlogin is for adding windows accounts. That is the reason you were getting the errors.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
January 26, 2014 at 2:45 pm
use sp_grantlogin to create windows users or groups:
sp_grantlogin @loginame = 'domain\users or groups'
in SQL2000, you need using sp_grantlogin to add windows users or groups
http://technet.microsoft.com/en-us/library/aa933411(v=sql.80).aspx
April 25, 2014 at 9:33 am
don't know hwo to delete it ...
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply