SQL Server Administration - User/Login Admin

Grant Database Access

Create a SQL Server Login. Note Microsoft states that this stored procedure will be deprecated and replaced by "Create User"

Syntax - SQL Server 2005/2008

sp_grantdbaccess [ @loginame = ] 'login'
    [ , [ @name_in_db = ] 'name_in_db' [ OUTPUT ] ]
GO

--returns 0=ok 1=failed

Example - SQL Server 2005/2008

EXEC sp_grantdbaccess 'SEASVR\ericm', 'ericm'
GO

Example - SQL Server 2008

-- sp_grantlogin calls CREATE USER so below is preferred method
CREATE USER ericm FOR LOGIN [SEASVR\ericm];
GO

 Collapse All    Expand All
Custom Search

SQL Server Information and Resources