Friday, May 21, 2010

User mapping in SQL Server 2005

--- Change database owner

EXEC [AdventureWorks].dbo.sp_changedbowner @loginame = N'sa', @map = false

--- Create database user to map SQL login account

CREATE USER [testdbuser] FOR LOGIN [testserverlogin]

--- Rename database user to a new name

ALTER USER [testdbuser] WITH NAME = NewNametestdbuser;

--- map database user to a SQL login account and Default Schema

ALTER USER [testdbuser] WITH login = [testserverlogin];
ALTER USER [testdbuser] WITH login = [testserverlogin] ,DEFAULT_SCHEMA =dbo;

No comments:

Post a Comment