SQL Server: Login Works, But Database [dbName] Is Unavailable

Using SQL Server 2012 on Windows 8.1, I recreated my OS account now recognized as a different user, which causes my old databases to be inaccessible. How can I resolve this issue?

hey swimmingfish, have you tried sp_change_users_login to resync the login with your datbase? i read that it may fix orphaned users. what do you think? might it be a good step, or do you have another approach? let me know how its goin!

After encountering a similar problem, I found that re-establishing the link between the server login and the corresponding database user proved effective. The process involved connecting to the target database and issuing an ALTER USER command to map the database user to the new login. This not only restored access but also resolved permission issues resulting from the account recreation. Reviewing the login’s default database setting and verifying that all object ownerships are correctly assigned also helped mitigate device-related discrepancies after the operating system account change.

hey swimmingfish, you might try droping the old user and re-creatin it in the db. this can flush out the mismatched mapping. sometimes a brief restert on sql server clears the cache too. hope it fixes ur issue!