Tuesday, January 07, 2014
How to Associate SQL Server Login with Existing Database User
Description
Sometimes a SQL Server Login is created and corresponding Database User is created at the same time. However, sometimes the Database User is not associated with a SQL Server Login and needs to be. For example, this could happen during an database environment migration or if when the Active Directory User Account associated with SQL Server Login is deleted and a new one is created.
Solution
The steps below can be used to lookup database principals and then associate a Login with a User.
1. Run the SELECT query below to view all database principals, including:
- DATABASE_ROLE
- SQL_USER
- WINDOWS_USER
SELECT * FROM sys.database_principals
2. Run ALTER USER query below to alter the database user and associate a login with it. In the example below, a Windows Login is being associated with a database user.
ALTER USER "DOMAIN\Username"
WITH
LOGIN = "DOMAIN\Username"
(Microsoft TechNet, 2014)
References
Bertrand, A. (November, 2013). Script to Set the SQL Server Database Default Schema For All Users. Retrieved January 7, 2014 from
http://www.mssqltips.com/sqlservertip/3098/script-to-set-the-sql-server-database-default-schema-for-all-users/
Microsoft TechNet (2014). ALTER USER (Transact-SQL). Retrieved January 7, 2014 from http://technet.microsoft.com/en-us/library/ms176060.aspx
Tharaka MTR (May, 2013). How to Fix Orphaned SQL Users. Retrieved January 7, 2014 from http://www.codeproject.com/Articles/594134/How-to-Fix-Orphaned-SQL-Users
Labels:
SQL Server,
SQL Server 2008,
SQL Server 2008 R2,
SQL Server 2012,
T-SQL
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2014
(24)
-
▼
January
(15)
- SharePoint 2013: Set-SPEnterpriseSearchTopology : ...
- SharePoint 2013: How to Rename the Search Service ...
- SharePoint 2013: How to Configure the Search Servi...
- Solution for Site Collection Lock, Missing Site Se...
- SharePoint 2013: How to Configure the Machine Tran...
- SharePoint 2013: How to Configure the PerformanceP...
- SharePoint 2013: How to Configure the Word Automat...
- SharePoint 2013: How to Configure the Excel Servic...
- SharePoint 2013: How to Configure the Access Servi...
- SharePoint 2013: How to Configure the Metadata Ser...
- SharePoint 2013: How to Configure the Business Dat...
- SharePoint 2013: How to Configure the Usage Servic...
- SharePoint 2013: How to Configure Secure Store Ser...
- SQL Server 2012: SELECT Machine Name, Server Name...
- How to Associate SQL Server Login with Existing Da...
-
▼
January
(15)
Events / Conferences / User Groups
- AIIM Conference
- Boston Area SharePoint User Group
- Boston Azure User Group
- Collaborate
- DevConnections
- DevIntersection
- Enterprise Search Summit
- Microsoft Build
- Microsoft SharePoint Conference
- Microsoft TechEd
- New England ASP.NET Professionals User Group
- New England Oracle Applications User Group
- Oracle Applications User Group (OAUG)
- Oracle OpenWorld
- PeopleSoft Government Contractor Special Interest Group
- PeopleSoft Southern New England Users Group
- Quest International Users Group
- SharePoint Saturday
- SPTechCon
- SQL PASS
- SQL Saturday
- Startup Weekend
No comments:
Post a Comment