Skip to content

Varinder Sandhu

Keep it Simple and Smart

  • Linkedin
  • Twitter
  • Facebook
  • RSS Feeds
  • Home
  • Submit Guest Post
  • Hire Me
  • Contact Me
  • About

SQL Server – Fix orphaned SQL users

Varinder Sandhu SQL, SQL-Query, SQL-Scripts, SQL-Tips and Tricks, Varinder Sandhu

Once you restore a Microsoft SQL Server database on a different machine, you cannot access the database until you fix the users.

The problem is that the user in the database is an “orphan”. This means that there is no login id or password associated with the database user

So before accessing database we need to maps an existing database user to a SQL Server login. For that use sp_change_users_login to link a database user in the current database with a SQL Server login. Using following steps we can fix orphaned SQL users

First we have to identify the “orphan” users. Below will lists the orphaned users:

EXEC  sp_change_users_login  'Report'
Go

If you have login ID myUser in security of Server and you db have user mydbUser then

EXEC  sp_change_users_login  'Update_One',  ‘mydbUser’,  ‘myUser’;
GO

If you want to create a new login id and password for this user, fix it by doing:

Exec  sp_change_users_login  ‘Auto_fix’, ’mydbUser’, ’myUser’, ’mypassword’;
Go

For detail see the
http://msdn.microsoft.com/en-us/library/ms174378.aspx

 

facebookShare on Facebook
TwitterPost on X
FollowFollow us
PinterestSave

Share this:

  • Tweet
  • WhatsApp
  • Share on Tumblr
  • Email
  • Threads
  • Telegram
  • More
  • Reddit
  • Pocket

Related

orphaned user, sp_change_users_login, SQL Server

Post navigation

« Add the value into an Identity Column in SQL Server
Query Optimization with Linked Server »

Search on VarinderSandhu.in

Other URL's

  • Badges – youracclaim
  • My Activities on MSDN
  • My Profile – Axelos
  • My RPA Certification

Recent Posts

  • App Store Optimization (ASO): Strategies To Ensure Success in a Fast-Moving Marketplace
  • Serverless Computing
  • WordPress Backup- WARNING: Job restarts due to inactivity for more than 5 minutes
  • How to Upgrade the PowerShell in Windows
  • 10 reasons why USA is the best country for immigrants

Categories

  • .Net Framework (6)
  • ASP.Net (12)
    • IIS (1)
    • LINQ (2)
    • MVC (3)
  • Big Data (3)
  • Blog-News (9)
  • C# (1)
  • Career Development (14)
  • Cloud Computing (3)
  • Crystal Report (2)
  • Data Migration (1)
  • Google (3)
  • Guest Post (35)
  • JavaScript (1)
  • Mobile App (1)
  • MS Office (8)
  • MySQL (1)
  • Networks (2)
  • Operating System (11)
    • Google Chrome (2)
    • Vista (1)
    • Window 7 (4)
    • Window 8 (1)
    • XP (1)
  • Oracle (39)
    • Oracle 11 G (1)
    • Oracle-Cursor (1)
    • Oracle-Tips and Tricks (31)
    • Oracle-Triggers (4)
    • Oracle-Utilities (5)
  • Others (43)
  • Outlook (6)
  • Powershell (1)
  • Share Point (3)
  • Software Development (2)
  • SQL (144)
    • SQL-Advanced (94)
    • SQL-Backup & Restore (13)
    • SQL-Cursor (1)
    • SQL-Functions(UDF) (1)
    • SQL-General (65)
    • SQL-Index (2)
    • SQL-Linked Server (4)
    • SQL-Performance (9)
    • SQL-Query (35)
    • SQL-Replication (8)
    • SQL-Reporting Services (5)
    • SQL-Scripts (44)
    • SQL-Server 2011 (6)
    • SQL-Server 2012 (14)
    • SQL-SSIS (6)
    • SQL-Stored Procedure (4)
    • SQL-Tips and Tricks (91)
    • SQL-Utilities (6)
  • Testing Tools (2)
  • Utilities (17)
  • Varinder Sandhu (266)
  • VB (3)
  • Visual Studio (6)

Archive Posts

Popular Tags

70-515 Authentication Career CollabNet Subversion Edge Database Database Backup Database Restore Denali Distributor Google Import/Export Wizard MCTS Microsoft Certified Technology Specialist MVC Oracle Outlook Packt Publishing Publisher Schema Server Side Trace SharePoint SQL SQL-Linked Server SQL-Server 2011 SQL Script SQL Server SQL SERVER 2008 SQL Server 2012 SQL Server Agent SQL Server Management Studio SSRS Stored Procedure Subscription Subversion temp table Tips and Tricks Toad Transactional Replication Trigger Varinder Sandhu Visual Studio Web Applications Web Communication Windows 7 wordpress

Follow me

  • LinkedIn
  • X
  • Facebook
  • RSS Feed

Google Translate

  • Copyright © 2024 www.varindersandhu.in
WordPress Theme: Smartline by ThemeZee.

Varinder Sandhu is using WP-Gravatar