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 SQL CREATE TABLE Statement. The CREATE TABLE statement is used to create a new table in a database.
CREATE LOGIN <loginname> WITH PASSWORD = '<Password>' MUST_CHANGE, CHECK_EXPIRATION = ON; Example to create a login for a user with password. The MUST_CHANGE option requires users to change this password the first time they connect to the server.
Description. The CREATE LOGIN statement creates an identity used to connect to a SQL Server instance. The Login is then mapped to a database user (so before creating a user in SQL Server, you must first create a Login).
Add users to database-level roles Log into your managed instance using a sysadmin account using SQL Server Management Studio. In Object Explorer, right-click the server and choose New Query. Create a new connection to the managed instance with the user that has been added to the db_datareader role.
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With