How to use the CREATE LOGIN sql statement?
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;
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;