How to use the CREATE LOGIN
statement on SQL Server 2005?
I've tried nearly everything: with commas, without them, with strings, without them, etc.
CREATE LOGIN @loginame WITH PASSWORD = 'pass',
DEFAULT_DATABASE='dbname' DEFAULT_LANGUAGE='us_english', CHECK_POLICY= OFF;
I always get this error:
Incorrect syntax near the keyword 'with'. If this statement is a
common table expression or an xmlnamespaces clause, the previous
statement must be terminated with a semicolon.
The best way is to use above statements but as a string, and then evaluete/exe this string as a command.
If you're running this in SSMS, you could use SQLCMD Mode (found under the Query menu) to script the variable for your login name.
:setvar LoginName "YourLoginName"
CREATE LOGIN $(LoginName) WITH PASSWORD = 'pass', DEFAULT_DATABASE='dbname' DEFAULT_LANGUAGE='us_english', CHECK_POLICY= OFF;
Do u want this Create login to be dynamic? Because u say @loginname?
I tried this code and it works for me..
CREATE LOGIN test WITH PASSWORD = 'pass', DEFAULT_DATABASE = [enter database here] , DEFAULT_LANGUAGE = us_english, CHECK_POLICY= OFF;