Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Msg 102, Incorrect syntax near '-'.

Author  Topic 

Peace2007
Posting Yak Master

239 Posts

Posted - 2009-01-05 : 00:54:40
Hi,
When I execute following query:
CREATE LOGIN [SQL2005-2\newUser] FROM WINDOWS WITH DEFAULT_DATABASE = [master]
I get: Msg 102...., Incorrect syntax near '-'.
when I modify the above query to:
CREATE LOGIN [[SQL2005-2]\newUser] FROM WINDOWS WITH DEFAULT_DATABASE = [master]
I get:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '-'.
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '\'.
Msg 319, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'with'...
Could I know how to resolve that?
Thanks in Advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-05 : 02:30:42
CREATE LOGIN [SQL2005-2]\newUser FROM WINDOWS WITH DEFAULT_DATABASE = [master]




E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Peace2007
Posting Yak Master

239 Posts

Posted - 2009-01-05 : 02:58:35
Thanks for the reply

It also works by:
CREATE LOGIN ['SQL2005-2'\newUser] FROM WINDOWS WITH DEFAULT_DATABASE = [master]
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2009-01-05 : 10:15:02
moved from script library

___________________________________________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.1 out!
Go to Top of Page

Peace2007
Posting Yak Master

239 Posts

Posted - 2009-01-10 : 01:00:44
sorry I didn't get u spirit
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-10 : 02:50:50
quote:
Originally posted by Peace2007

sorry I didn't get u spirit


you had posted in wrong forum. script library is for posting scripts created by posters. thats why spirit moved it to relevant forum.
Go to Top of Page
   

- Advertisement -