Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
Create login - domain name with '.'
Create login - domain name with '.'
Rate Topic
Display Mode
Topic Options
Author
Message
victorel
victorel
Posted Wednesday, September 19, 2012 3:14 PM
Forum Newbie
Group: General Forum Members
Last Login: Thursday, November 29, 2012 4:13 PM
Points: 2,
Visits: 10
Hi
I'm trying to create a simple script to allow Network Service accout to access my database
DECLARE @user NVARCHAR(50)
SET @user = ABC.COM\ABC105$'
DECLARE @SQL NVARCHAR(4000);
SET @SQL = 'CREATE LOGIN [' + @user + '] FROM WINDOWS WITH DEFAULT_DATABASE=[master]'
EXECUTE(@SQL);
SET @SQL = 'CREATE USER [' + @user + '] FOR LOGIN ['+@user+'] WITH DEFAULT_SCHEMA=[dbo]'
EXECUTE(@SQL);
EXEC sp_addrolemember 'db_owner', @user
GO
The script fails with the message:
Msg 15401, Level 16, State 1, Line 1
Windows NT user or group 'ABC.COM\ABC105$' not found. Check the name again.
if I just execute
CREATE LOGIN ABC.COM\ABC105$ FROM WINDOWS WITH DEFAULT_DATABASE=[master]
it says
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'.
How do I fix that?
Thanks in advance
Post #1361646
victorel
victorel
Posted Wednesday, September 19, 2012 3:32 PM
Forum Newbie
Group: General Forum Members
Last Login: Thursday, November 29, 2012 4:13 PM
Points: 2,
Visits: 10
Hmmm I figured it out myself. The domain should not include the .com portion. Not clear why though
Post #1361662
Kenneth.Fisher
Kenneth.Fisher
Posted Wednesday, September 19, 2012 11:03 PM
Hall of Fame
Group: General Forum Members
Last Login: 2 days ago @ 1:16 PM
Points: 3,367,
Visits: 1,567
Just out of curiosity give this a try:
CREATE LOGIN [ABC.COM]\ABC105$ FROM WINDOWS WITH DEFAULT_DATABASE=[master]
Kenneth Fisher
I strive to live in a world where a chicken can cross the road without being questioned about its motives.
--------------------------------------------------------------------------------
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Link to my Blog Post -->
www.SQLStudies.com
Post #1361732
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.