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
 SQL Server Administration (2005)
 Create login

Author  Topic 

ServerTeam
Yak Posting Veteran

83 Posts

Posted - 2008-06-02 : 11:14:19
HI Gurus,


When ia m trying to create
CREATE LOGIN [ADVWORKS\fogisu] FROM WINDOWS;

thrus error as
Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'LOGIN'.

can some one pls help me in this..

Thanks,
ServerTeam

mdubey
Posting Yak Master

133 Posts

Posted - 2008-06-02 : 11:38:04
Syntax
CREATE LOGIN login {WITH PASSWORD = 'password'
[HASHED] [MUST_CHANGE]
[, option_list [ ,... ] ]}

CREATE LOGIN login {FROM sources}

sources:
WINDOWS [ WITH windows_options [ ,... ] ]
CERTIFICATE certname
ASYMMETRIC KEY asym_key

option_list:
SID = sid
DEFAULT_DATABASE = database
DEFAULT_LANGUAGE = language
CHECK_EXPIRATION = {ON | OFF}
CHECK_POLICY = {ON | OFF}
CREDENTIAL = credential

windows_options:
DEFAULT_DATABASE = database
DEFAULT_LANGUAGE = language

Key:
login Login: SQL Server / certificate-mapped / asymmetric key-mapped / [Windows].
WINDOWS Map to a Windows login.
certname Certificate to associate with this login.
asym_key Name of an asymmetric key to associate with this login.
password A SQL Server login password for the login.
HASHED The SQL Server login is already hashed. (so don't hash again)
MUST_CHANGE Prompt the user for a new SQL Server password
credential Credential to be mapped to the new SQL Server login.
sid GUID of the new SQL Server login. (default=automatic)
DEFAULT_DATABASE The default database to be assigned to the login.(default = master)
DEFAULT_LANGUAGE The default language to be assigned to the login.
CHECK_EXPIRATION Enforce password expiration policy
CHECK_POLICY Enforce Windows password policyPasswords are case-sensitive.

Prehashing of passwords is supported only when you are creating SQL Server logins.

If MUST_CHANGE is specified, CHECK_EXPIRATION and CHECK_POLICY must be set to ON.

Examples

CREATE LOGIN [SERVER01\User01] FROM WINDOWS;GO

CREATE LOGIN user42 WITH PASSWORD = 'pa$$word' MUST_CHANGE;GO

Manoj
MCP, MCTS
Go to Top of Page

ServerTeam
Yak Posting Veteran

83 Posts

Posted - 2008-06-03 : 10:04:51
i don't want to create with password.

Just create login...

Thanks,
ServerTeam
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-06-03 : 10:36:29
Windows admin should create login before you can assign permission.
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-06-03 : 16:18:23
>> CREATE LOGIN [ADVWORKS\fogisu] FROM WINDOWS;

This is sample code in books online, you have to replace [ADVWORKS\fogisu] with login from your domain.
Go to Top of Page

ServerTeam
Yak Posting Veteran

83 Posts

Posted - 2008-06-04 : 09:22:38
did same thing..got following error..

Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'LOGIN'.

Thanks,
ServerTeam
Go to Top of Page

ServerTeam
Yak Posting Veteran

83 Posts

Posted - 2008-06-04 : 09:27:23
This is on 2000 SERVER.

Thanks,
ServerTeam
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-06-04 : 09:54:39
use master

declare @login_name sysname

set @login_name = N'MyDomain\MyLogin'

if not exists (select * from master.dbo.syslogins where loginname = @login_name)
begin
exec sp_grantlogin @login_name
exec sp_defaultdb @login_name, N'master'
exec sp_defaultlanguage @login_name, N'us_english'
end


CODO ERGO SUM
Go to Top of Page
   

- Advertisement -