Learn Sql Server   Learn Sql Theory   Learn Sql

 
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7

Sql Server web services

Sql Server HTTP Endpoints

Creating an HTTP Endpoint

Managing HTTP Endpoint Security

Modifying an HTTP Endpoint

Removing an HTTP Endpoint

Reserving an HTTP Namespace

Sql Server Error Handling

Creating a User-Defined Error Message using sp_addmessage

Dropping a User-Defined Error Message Using sp_dropmessage

Sql Server RAISERROR

Using TRY CATCH

Error Handling with TRY...CATCH

Nesting TRY...CATCH Calls

Sql Server Principals

Creating a Windows Login

Viewing Windows Logins

Altering a Windows Login

Dropping a Windows Login

Denying SQL Server Access to a Windows User or Group

Sql Server Authentication

Creating a SQL Server Login

Viewing SQL Server Logins

Altering a SQL Server Login

Dropping a SQL Login

Managing Server Role Members

Reporting Fixed Server Role Information

Database Principals

Creating Database Users

Reporting Database User Information using sp_helpuser

Modifying a Database User

Removing a Database User from the Database

Fixing Orphaned Database Users

Reporting Fixed Database Roles Information

Managing Fixed Database Role Membership

Managing User-Defined Database Roles

Managing Application Roles

Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Chapter 16

Creating a SQL Server Login

This example first demonstrates how to create a SQL Server login with a password and a default database designated:

CREATE LOGIN Veronica
WITH PASSWORD = 'InfernoII',
DEFAULT_DATABASE = AdventureWorks

Assuming you are using Windows 2003 Server or higher, as well as mixed authentication, the recipe goes on to create a SQL login with a password that must be changed the first time the user logs in. This login also is created with the CHECK_POLICY option ON, requiring it to comply with Windows password policies:

CREATE LOGIN Trishelle
WITH PASSWORD = 'ChangeMe' MUST_CHANGE ,
CHECK_EXPIRATION = ON,
CHECK_POLICY = ON

How It Works


The first example in this recipe demonstrated creating a SQL login named Veronica. The login name was designated after CREATE LOGIN:
CREATE LOGIN Veronica
The second line designated the login’s password:
WITH PASSWORD = 'InfernoII',
The last line of code designated the default database that the login’s context would first enter after logging into SQL Server:
DEFAULT_DATABASE = AdventureWorks
The second SQL login example demonstrated how to force a password to be changed on the first login by designating the MUST CHANGE token after the password:
CREATE LOGIN Trishelle
This password policy integration requires Windows 2003 Server, as did the password expiration and password policy options also designated for this login:
CHECK_EXPIRATION = ON,
CHECK_POLICY = ON

Sponsored Links