Create a login

The login must be the user's identity as a Windows account or one that uses Windows Authentication. The following procedure shows code that authorizes a user who is named DA_Mary, and who is authenticated by a computer or Active Directory, to access this instance of SQL Server.

If more than one instance of SQL Server 2005 exists on the computer, you must create the login on each instance that DA_Mary must access.

To create a login

  • In a Query Editor window of SQL Server Management Studio, type and run the following code, replacing domain_name with the name of the appropriate network.

    CREATE LOGIN [domain_name\DA_Mary]
        FROM WINDOWS
        WITH DEFAULT_DATABASE = [Staging_TestData];
    GO
    

    FROM WINDOWS indicates that Windows will authenticate the user. The optional DEFAULT_DATABASE argument connects DA_Mary to the TestData database, unless the connection string indicates another database. This statement introduces the semicolon as an optional termination for a Transact-SQL statement.

另请参阅