%3CLINGO-SUB%20id%3D%22lingo-sub-1715332%22%20slang%3D%22en-US%22%3ECannot%20find%20SQL%20instance%20when%20applying%20patch%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1715332%22%20slang%3D%22en-US%22%3E%3CP%3EOne%20customer%20had%20a%20SQL2016%20SP1%20instance.%20We%20can%20login%20this%20instance%20without%20any%20issue.%20But%20when%20we%20tried%20to%20apply%20SQL2016%20SP2%20in%20this%20server.%20We%20cannot%20find%20SQL%20instance%20in%20below%20panel.%20Only%20%E2%80%98Shared%20Features%E2%80%99%20are%20listed.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Bob_Cai_1-1601078963691.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222339i77EAD7BCF8FA5163%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Bob_Cai_1-1601078963691.png%22%20alt%3D%22Bob_Cai_1-1601078963691.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20decompiled%20SQL%20setup%20dlls.%20It%20seems%20that%20SQL%20setup%20should%20check%20below%20registry%20key%20to%20Enumerate%20SQL%20Server%20features.%3CBR%20%2F%3E%3CBR%20%2F%3EHKEY_LOCAL_MACHINE%5CSOFTWARE%5CMicrosoft%5CWindows%5CCurrentVersion%5C%3CSTRONG%3EUnistall%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Bob_Cai_2-1601078963761.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222341i185F38F3773ECDE0%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Bob_Cai_2-1601078963761.png%22%20alt%3D%22Bob_Cai_2-1601078963761.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20found%20below%20key%20was%20missing%20in%20customer%E2%80%99s%20environment.%20We%20tried%20to%20remove%20below%20key%20in%20my%20testing%20environment.%20We%20can%20reproduce%20the%20same%20issue.%3C%2FP%3E%0A%3CP%3EHKEY_LOCAL_MACHINE%5CSOFTWARE%5CMicrosoft%5CWindows%5CCurrentVersion%5CUninstall%5CMicrosoft%20SQL%20Server%2013%3C%2FP%3E%0A%3CP%3EHowever%2C%20after%20adding%20back%20above%20key.%20SQL%20instance%20is%20still%20not%20found%20in%20patching%20in%20customer%E2%80%99s%20environment.%20So%20we%20still%20need%20to%20check%20the%20keys%20in%20%E2%80%98HKEY_LOCAL_MACHINE%5CSOFTWARE%5CMicrosoft%5CWindows%5CCurrentVersion%5CUnistall%E2%80%99.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20found%202%20product%20codes%20are%20related%20with%20%3CSTRONG%3ESQL%20Server%202016%20database%20Engine%20service%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Bob_Cai_3-1601078963789.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222340i61E131AA413A0518%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Bob_Cai_3-1601078963789.png%22%20alt%3D%22Bob_Cai_3-1601078963789.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Bob_Cai_4-1601078963806.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222342iAD505F230AC253D0%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Bob_Cai_4-1601078963806.png%22%20alt%3D%22Bob_Cai_4-1601078963806.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBut%20according%20to%20the%20name%20of%20msi%20package%2C%26nbsp%3B%20%7B51574D2C-DE28-4441-BDC2-967F0FFC0918%7D%20is%20the%20real%20database%20engine%20service%20product%20code.%3C%2FP%3E%0A%3CP%3EWe%20can%20also%20run%20PowerShell%20scripts%20to%20verify.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Bob_Cai_5-1601078963846.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222343i68BC414F4950C980%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Bob_Cai_5-1601078963846.png%22%20alt%3D%22Bob_Cai_5-1601078963846.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Bob_Cai_6-1601078963901.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222344i579F242CE5026E93%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Bob_Cai_6-1601078963901.png%22%20alt%3D%22Bob_Cai_6-1601078963901.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20found%20below%20registry%20keys%20have%20%7B0C457EC3-E998-4041-B856-908D5A2C1708%7D%20in%20%22ProductCode%22.%20But%20it%E2%80%99s%20incorrect.%3C%2FP%3E%0A%3CP%3E%5BHKEY_LOCAL_MACHINE%5CSOFTWARE%5CMicrosoft%5CMicrosoft%20SQL%20Server%5CMSSQL13.MSSQLSERVER%5CSetup%5D%3CBR%20%2F%3E%5BHKEY_LOCAL_MACHINE%5CSOFTWARE%5CMicrosoft%5CMicrosoft%20SQL%20Server%5CMSSQL13.MSSQLSERVER%5CSetup%5CSQL_Engine_Core_Inst%5D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWe%20finally%20resolved%20this%20issue%20by%20making%20below%20changes.%20Those%202%20wrong%20product%20codes%20caused%20this%20issue.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%5BHKEY_LOCAL_MACHINE%5CSOFTWARE%5CMicrosoft%5CMicrosoft%20SQL%20Server%5CMSSQL13.MSSQLSERVER%5CSetup%5D%3CBR%20%2F%3E%22ProductCode%22%3D%22%7B0C457EC3-E998-4041-B856-908D5A2C1708%7D%22%20%26nbsp%3Bchange%20to%20%7B51574D2C-DE28-4441-BDC2-967F0FFC0918%7D%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%20start%3D%222%22%3E%0A%3CLI%3E%5BHKEY_LOCAL_MACHINE%5CSOFTWARE%5CMicrosoft%5CMicrosoft%20SQL%20Server%5CMSSQL13.MSSQLSERVER%5CSetup%5CSQL_Engine_Core_Inst%5D%3CBR%20%2F%3E%22ProductCode%22%3D%22%7B0C457EC3-E998-4041-B856-908D5A2C1708%7D%22%20change%20to%20%7B51574D2C-DE28-4441-BDC2-967F0FFC0918%7D%3C%2FLI%3E%0A%3C%2FOL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1715332%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Bob_Cai_0-1601078933781.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F222338iFFD37E02C0438AD0%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Bob_Cai_0-1601078933781.png%22%20alt%3D%22Bob_Cai_0-1601078933781.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Microsoft

One customer had a SQL2016 SP1 instance. We can login this instance without any issue. But when we tried to apply SQL2016 SP2 in this server. We cannot find SQL instance in below panel. Only ‘Shared Features’ are listed.

Bob_Cai_1-1601078963691.png

 

I decompiled SQL setup dlls. It seems that SQL setup should check below registry key to Enumerate SQL Server features.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Unistall

Bob_Cai_2-1601078963761.png

 

We found below key was missing in customer’s environment. We tried to remove below key in my testing environment. We can reproduce the same issue.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft SQL Server 13

However, after adding back above key. SQL instance is still not found in patching in customer’s environment. So we still need to check the keys in ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Unistall’.

 

We found 2 product codes are related with SQL Server 2016 database Engine service.

Bob_Cai_3-1601078963789.png

 

Bob_Cai_4-1601078963806.png

 

But according to the name of msi package,  {51574D2C-DE28-4441-BDC2-967F0FFC0918} is the real database engine service product code.

We can also run PowerShell scripts to verify.

Bob_Cai_5-1601078963846.png

 

Bob_Cai_6-1601078963901.png

 

We found below registry keys have {0C457EC3-E998-4041-B856-908D5A2C1708} in "ProductCode". But it’s incorrect.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL13.MSSQLSERVER\Setup]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL13.MSSQLSERVER\Setup\SQL_Engine_Core_Inst]

 

We finally resolved this issue by making below changes. Those 2 wrong product codes caused this issue.

 

  1. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL13.MSSQLSERVER\Setup]
    "ProductCode"="{0C457EC3-E998-4041-B856-908D5A2C1708}"  change to {51574D2C-DE28-4441-BDC2-967F0FFC0918}

 

  1. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL13.MSSQLSERVER\Setup\SQL_Engine_Core_Inst]
    "ProductCode"="{0C457EC3-E998-4041-B856-908D5A2C1708}" change to {51574D2C-DE28-4441-BDC2-967F0FFC0918}