Saturday, September 13, 2025

Troubleshooting the “Cannot Generate SSPI Context” Error After SQL Server Migration

 Introduction

After a recent SQL Server migration from 2012 to 2022, our team encountered a classic authentication issue:
The target principal name is incorrect. Cannot generate SSPI context.


Youtube video:



This blog post details my real-world journey identifying the root cause, the steps I followed, and key lessons for database administrators facing similar challenges.


Scenario: Local Logins Fine, Remote Logins Fail

An end user reported:

  • Local login (from the server running SQL Server) succeeded via Windows Authentication.

  • Remote login (from another server or workstation) repeatedly failed with the SSPI context error above.

Such errors often point to problems with Kerberos authentication, host/service principal names, or SQL Server’s service account configuration.


Background: What Changed During Migration?

Our upgrade steps involved:

  1. Set up SQL Server 2022 on a new, upgraded Windows Server.

  2. Restore databases from the SQL Server 2012 instance onto the new server.

  3. Switch hostnames and IP addresses so that the new server replaced the old one.

Following these changes, remote Windows Authentication was broken—prompting our investigation.


Step 1: Initial Troubleshooting

As DBA, I:

  • Tried various SSMS versions (2012, 2022) from remote machines; both failed with the same error.

  • Attempted connections using the hostname and IP address—no luck.

  • Checked which service account was running the new SQL Server instance and found it used a virtual account:
    NT Service\MSSQLServer

  • Realized we didn’t know what service account the old (source) SQL Server used—the migration team hadn’t recorded it before decommissioning the old server.


Step 2: Investigating the Old Server’s Service Account (Without Booting It!)

Instead of powering up the old server just to check the service account, I coordinated with the backup team to recover the system’s Windows Registry “hive” files from backup:

  • SYSTEM

  • SOFTWARE

  • SECURITY

  • SAM

  • DEFAULT

Safely Loading Old Registry Hives

Because hive files are raw binaries, importing them directly might overwrite or corrupt settings on the new server. To avoid this, here’s the safe approach I followed:

1. Save the Registry Hive (on test machine, not live!)

In case of real life scenario, you will restore the hive files to your local test machine from the decommissioned server. For testing purpose, here we are saving the files from current machine itself.
powershell
reg save HKLM\SYSTEM D:\temp\SYSTEM.bkp

2. Set Variables & Create a Temporary Branch

powershell
$HivePath = "D:\temp\SYSTEM.bkp" $TempKey = "TempSYSTEM"

3. Load the Hive Temporarily

powershell
reg.exe load "HKLM\$TempKey" "$HivePath"

4. Explore the Old Registry in regedit

  • Open Registry Editor. You should see a new branch (TempSYSTEM) containing the old server’s settings.

  • Locate SQL Server’s service account.

5. Clean Up

powershell
reg.exe unload "HKLM\$TempKey"

Step 3: What I Found and Why It Mattered

  • The original (source) server used:
    NT Authority\NetworkService

  • The new (target) server was using:
    NT Service\MSSQLServer (a virtual account)

Why is this important?
The NetworkService account is a domain account, enabling Kerberos across the network. A virtual account is local-only and cannot register Service Principal Names (SPNs) in Active Directory—making Kerberos authentication for remote logins impossible.


Kerberos, SPNs, and SQL Server: Key Takeaways

  • Domain service accounts or Group Managed Service Accounts (gMSA) are recommended for SQL Server where Kerberos authentication or cross-host access is needed.

  • Virtual accounts are more restrictive—best for standalone, local-only database access.

  • SPNs for SQL Server must be registered in Active Directory for Kerberos to function. Virtual accounts can’t do this natively.

In summary:
Our migration accidentally moved a network-accessible SQL Server to a self-contained setup, restricting external access and breaking Kerberos logins.


Conclusion: Migration Lessons Learned

  • Document your SQL Server service account configuration before any migration!

  • For environments where remote Windows Authentication is required, always use a domain account or gMSA—not just a local virtual account.

  • Registry hive analysis is a safe and powerful way to recover configuration from offline systems without booting up or risking the production environment.


If you found this guide useful, consider sharing it with fellow DBAs or IT professionals managing SQL Server migrations. Questions? Leave a comment!



---------------- Hand written notes below -----------------------------------

Objective: Troubleshoot one of the reasons for the below error in MSSQL.


The target principal name is incorrect. Cannot generate SSPI context


Situation: End user reporting that they are facing the below condition..

a. Login using windows authentication from the same server (where sqlserver runs) works fine

b. Login using remote server fails with the message highlighted above


In the process of troubleshooting, we learn the following....


1. There was a sqlserver upgrade or migration from 2012 to 2022; which involves the following...

a. Setup SQLServer 2022 in a new server (since we need to upgrade the windows server as well)

b. Backup/restore the db from 2012 (old machine) to 2022 (new machine).

c. Switch the names of the old and new machine including IP address.


2. Post this end users are reporting the problem highlighted above. As a DBA I did the following..

a. I validated if SSMS version has any issues from remote server, both version 2012 and version 20 both failed with same message

b. I changed the hostname (from remote server) in ssms to connect to actual hostname, ip, still the same error

c. Validated the service used for MSSQL instane

i)Service name: NT Service\MSSQLServer [this is a virtual account]

d. But what was the service account used in source server, the team which performed the migration didnt notice the service account config from source. The server is shutdown.

i) The server can be brought back online to examine the service account usage -- but that will be a last resort.

ii) So the server backup at vmlevel was secured

1) I requested the backup team to navigate to the registry hive file located under C:\Windows\System32\config

2) restore all the following hive files: SYSTEM, SOFTWARE, SECURITY, SAM, DEFAULT

3) Now is the tricky situation, how will I asses the hive files???

Hive files are kind of db binary file in raw format. When it is loaded to registry using regedit>Import, you can access the data in readable format.

But if you load asis, you will purge or overwrite the target machine setting.

To prevent this situation we need to follow the below procedure


Step 1)

##for testing, you cant access live registry. So you need to save registry in raw format using this command:

##powershell in admin mode:


reg save HKLM\SYSTEM D:\temp\SYSTEM.bkp


In real life scenario, you will restore the hive files from backup of the old machine.


Step 2)

##Store path of the hive file from above

$HivePath = "D:\temp\SYSTEM.bkp"


Step 3)

##Create a temporary branch to load the hive file in current server itself, this will avoid registry overwrite

$TempKey = "TempSYSTEM"


Step 4)

## Load the registry key

reg.exe load "HKLM\$TempKey" "$HivePath"


Step 5) OPen regedit, you should see the new branch and registry from old system loaded here. Now we can assess whatever we need; for example MSSQL service account details.


Step 6) Close regedit.


Step 7) Unload the registry


reg.exe unload "HKLM\$TempKey"


Step 8) open regedit and examine if you still see the temporary branch


====Actual output:

PS C:\Windows\system32> reg save HKLM\SYSTEM D:\temp\SYSTEM.bkp

The operation completed successfully.

PS C:\Windows\system32> cd D:\temp\

PS D:\temp> dir



    Directory: D:\temp



Mode                 LastWriteTime         Length Name

----                 -------------         ------ ----

-a----        10/09/2025     22:33       20422656 SYSTEM.bkp



PS D:\temp> $HivePath = "D:\temp\SYSTEM.bkp"

PS D:\temp> $TempKey = "TempSYSTEM"

PS D:\temp> reg.exe load "HKLM\$TempKey" "$HivePath"

The operation completed successfully.

PS D:\temp> reg.exe unload "HKLM\$TempKey"

The operation completed successfully.

=====================


So this is how you can assess a particular root cause. In my case the service account config was improper in the target.


Source: NT Authority\NetworkService

Target: NT Service\MSSQLSERVER


The earlier one allows network access of the db (kerberos setup), later virtual account doesnt allow that.


SPNs and Kerberos: With a domain service account or gMSA, SPNs for MSSQLSvc can be registered and managed centrally; with virtual accounts, SPNs are not auto-registered in AD, so a domain account is preferred when Kerberos is required across hosts.

So the DBA who migrated the db, brought a network accessed db into a self constrained setup trimming all external access (more restricted setup by using virtual account).

-------------------

Tuesday, August 12, 2025

Notes: XTTS incremental other way in same endianness

 XTTS incremental other way in same endianess:


Setup physical standby

Put tbspsc in ro

Stop replication

expdp full=y transportable=always

shutdown standby

keep other skeleton alive

impdp transport_Datafiles=<df list from standby>



So we achieve the XTTS incremental method here :)


This standby setup and replication usage in XTTS is hinted in 11.2 XTTS guide for cross platform.

Thursday, August 7, 2025

Real-Life Scenario Testing: Perplexity.ai Comet AI Browser

Real-Life Scenario Testing: Perplexity.ai Comet AI Browser

Perplexity.ai’s Comet AI browser is redefining what it means to work with intelligent browsing and automation. In this post, I share my hands-on experience putting Comet through a battery of real-life scenario tests—from intelligent search to coding assistance to web automation. Here’s an in-depth breakdown.

Youtube: 


Introduction and Purpose

The journey starts with a quick overview of why Comet AI browser is different and what the goal of these scenario tests is.

Experience with A.I. Models and Perplexity

With years of experience in AI and tech, I provide context for why Perplexity’s approach stands out, and the types of problems it aims to solve.

First Impressions: Features of Comet Browser

Exploring the sleek, innovative browser interface, I list standout features and compare them to conventional browsers.

YouTube Search Scenario

Putting Comet to the test, I check its skill in finding and summarizing YouTube content—turning a generic search into targeted knowledge retrieval.

Oracle Migration Script Scenario

Comet helps build and validate a complex Oracle migration script, showing off its development chops for enterprise challenges.

Chess.com Automation Test

Watch as Comet automates a game scenario on Chess.com, showcasing fluid web automation and smart task sequencing.

SQL Coding with livesql.oracle.com

From automating solutions to offering on-the-fly code fixes, I demonstrate how Comet can support both beginners and experts with SQL tasks.

Draw.io Architecture Diagram Challenge

I test Comet’s interactive capabilities by asking it to visually design a complicated architecture diagram in draw.io from just a text prompt.

Draw.io: Challenges & Repeated Attempts

Detailed look at the trial-and-error process, where each attempt brings new insights and approaches to solving diagram tasks.

Third Attempt and Discussion

A candid discussion on iterative improvement and learning curves using advanced AI-assisted workflows.

Feedback and Lessons Learned

I summarize the practical insights gained from using Comet, including tips for new users and what to watch for.

Conclusion & Takeaways

Rounding off the tests, I share my verdict: Comet is a powerful assistant for anyone looking to automate, learn, and boost productivity with AI-powered browsing.

Whether you are a tech enthusiast, developer, or just AI-curious, Perplexity.ai’s Comet browser deserves a spot in your digital toolkit. Try it for yourself and share your experiences below!


--------Actual handwritten text below---------

Try comet - perplexity's comet AI browser


What it is?

1. AI browser

2. Integerated with Perplexity AI engine

3. Agentic AI capable

4. Can control and perform tasks on bahalf of you in the browser window - browser assistant

5. Voice mode control is possible as well



Scenarios we are going to test:


1. Look for a specific video and action in youtube

Prompt: Search a video in youtube which show cases postgresql reaching 100k transactions per minute, navigate the video to the precise timeline.

Job: Completed


Prompt: Search a video in youtube which shows XTTS incremental v4 migration script failing because of TDE, navigate the video to the precise timeline.

Job: Completed -- Aced it


2. Play the game of chess aginst bot

prompt: Take over the chess game from me and try to win the game in less than 5 moves

Job: Failed after 3 moves, gave up.


3. Test SQL capability:

Prompt: Connect to livesql.oracle.com, try running a simple analytical query involving connect by clause

Job: Duece


4. Create the below architectural diagram using draw.io for BMC's control M stack

Prompt: Develop an interactive architectural diagram in draw.io for BMC's control M stack involving oracle as rdbms stack with dataguard for high availability. 

                Ensure the architecture diagram shows few client machines and end user interactions. The end users are sitting within W365 infrastructure. The actual control M servers and client machines are in azure cloud.

The HA setup for oracle should reside in 2 different azure regions.

The Control M and Enterprise manager stacks should sit in 2 different azure regions.

Use draw.io to draw an architectural diagram for BMC's control M stack involving oracle as rdbms stack with dataguard for high availability. 

                Ensure the architecture diagram shows few client machines and end user interactions. The end users are sitting within W365 infrastructure. The actual control M servers and client machines are in azure cloud.

The HA setup for oracle should reside in 2 different azure regions.

The Control M and Enterprise manager stacks should sit in 2 different azure regions.


Job: Failed, 3rd attempt was brave.


Tuesday, August 5, 2025

AI Use case: Assess vmstat data using gemini and generate charts and summary of the observation

Objective: Assess vmstat data using gemini and generate charts and summary of the observation.

CPU Loader:

for i in 1; do while : ; do : ; done & done


Ask AI to process first the raw vmstat output: It mostly will fail

Prompt for raw data processing:

Can you please process the attached vmstat file and generate a vertically sliced metrics chart and summary?

Failed!!!!

A) preprocess in notepad++

1) Replace all whitespaces to , in notepad++

find: \x20+ 

repace: ,

2)First character to become ,:

find: ^(\d+)\,

replace: ,$1,

3) Remove the repeated vmstat headers
find and bookmark such lines 
delete all bookmarked lines

Ask AI now to process the preprocessed output file and generate graph. It will succeed
prompt: Can you please process the attached vmstat csv file and generate a vertically sliced metrics chart and summary?

Outputs:

First version:

Revisions:








This should help!
Thanks

ORA-08177 Oracle RDBMS & Spring Batch framework

 Dear Readers,

Migration from Oracle RAC to Standalone database resulted in ORA-08177 error with few batch processes.


ORA-08177: can't serialize access for this transaction


The uniqueness amongst the batches are they are all written using spring batch frame work.

I saw the data model of the frame work on the db and I can confirm they are spring batch.

It had all the tables as mentioned in the below screenshot. The same can be found here



The reason for the error is even documented in the spring batch framework document here.



But one would wonder why such error message may come...

1. Since it is the same serialization in both standalone and rac db. But why standalone alone affected vs RAC no impact for several years.

2. No concurrent transactions were run on the db

This is where oracle on the SR I submitted confirmed that oracle RAC's multi cache gc related events handles the serialization transaction much better than oracle standalone's single cache.

So a pure technology change resulted in such behaviour.

This happened only with spring batch, other java programs behaved same.


Thanks