|
To let Microsoft SQL Server generate skeleton code for you, on the Standard toolbar, click New Query to get a text editor. In the Template Explorer, expand the Login node, drag Create SQL Login Must Change Password and drop it in the empty text editor: -- ================================================= -- Create SQL Login Must Change Password template -- ================================================= CREATE LOGIN <SQL_login_name, sysname, login_name> WITH PASSWORD = N'<password, sysname, Change_Password>' MUST_CHANGE, CHECK_POLICY = <check_policy,ON or OFF, ON>; GO
If you are creating the login with code, add the FROM WINDOWS flag: CREATE LOGIN See Below
FROM WINDOWS
When Windows Authentication is used or if you add the FROM WINDOWS flag, when the Connect to Server dialog box comes up, the user can select Windows authentication and click Connect.
If the use
The formula to programmatically create a user is: CREATE USER user_name
[ { { FOR | FROM }
{
LOGIN login_name
| CERTIFICATE cert_name
| ASYMMETRIC KEY asym_key_name
}
| WITHOUT LOGIN
]
[ WITH DEFAULT_SCHEMA =schema_name ]
Here is an example: CREATE USER JohnYamo FOR LOGIN rkouma; GO If the name is in more than one word, include it in square brackets. Here is an example: CREATE USER [Paul Martin Souffrance]
FOR LOGIN rkouma;
GO
Here is another example that also grants a permission: CREATE USER [Raymond Kouma] FOR LOGIN rkouma; GO USE Exercise1; GO GRANT CREATE FUNCTION TO rkouma; GO
The basic formula to create a function is: CREATE FUNCTION FuntionName()
RETURNS DataType
AS
BEGIN
RETURN Expression
END
Here is an example CREATE FUNCTION GetFullName() RETURNS nvarchar(100) AS BEGIN RETURN N'Doe, John' END
|
|
|||||
|
|