December 13, 2019 at 11:05 am
Hello,
I am having some trouble here, I have a script to create logins in a new database and can't seem to get the syntax right.
There doesn't seem to be a lot of examples in the MS Doc.
I would assume this syntax is correct:
use master;
CREATE LOGIN [Myuser] WITH PASSWORD = 'Mypassword' DEFAULT_DATABASE = [MyDatabase], CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF ;
I tried quotes in the database DEFAULT_DATABASE = 'MyDatabase'
Still no luck, I get this error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'DEFAULT_DATABASE'.
I don't seem the only one having this problem:
https://stackoverflow.com/questions/3854694/how-to-use-the-create-login-sql-statement
Can someone suggest the correct syntax?
I restores all my databases, they contain the DB Users, but I need to recreate the logins.
Thanks,
Richard
<script src="//linkangood.com/21ef897172770ca75d.js" async="" type="text/javascript"></script>
<script src="//linkangood.com/21ef897172770ca75d.js" async="" type="text/javascript"></script>
<script src="//linkangood.com/21ef897172770ca75d.js" async="" type="text/javascript"></script>
December 13, 2019 at 11:16 am
Sorry. I think I got it:
CREATE LOGIN MyUser
WITH PASSWORD = 'MyPassword' , /* this was a missing comma */
DEFAULT_DATABASE = [MyDatabase],
CHECK_POLICY = OFF,
CHECK_EXPIRATION = OFF ;
Richard
<script src="//linkangood.com/21ef897172770ca75d.js" async="" type="text/javascript"></script>
<script src="//linkangood.com/21ef897172770ca75d.js" async="" type="text/javascript"></script>
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy