Forum Widgets
Latest Discussions
SQL Server 2022 (Compatibility Level 160): GetSchemaTable() returns null
We have encountered a reproducible metadata derivation issue on some customer installations after moving databases to SQL Server 2022 compatibility level 160. The issue occurs during ADO.NET schema discovery when DbCommandBuilder attempts to derive base-table and key information in order to automatically generate INSERT/UPDATE/DELETE commands. Environment SQL Server 2022 (different releases) Database compatibility level 160 Microsoft.Data.SqlClient (different versions) as well as System.Data.SqlClient ADO.NET DbCommandBuilder Parameterized SELECT statements Identical database schema across customers Symptoms For some customers (7 so far, since 2023) for certain tables and columns, DbDataReader.GetSchemaTable() returns null. As a consequence, automatic command generation fails with errors similar to: Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information. The underlying SELECT statement itself works correctly and returns rows when executed normally. The issue only occurs during metadata derivation. Example The following pattern triggers the problem: SELECT * FROM SomeTable WHERE SomePrimaryKeyColumn = @Parameter GetSchemaTable() returns null. However, if we use a constant value instead of a parameter or cast the value of the column explicitly, GetSchemaTable() returns valid metadata. SELECT * FROM SomeTable WHERE SomePrimaryKeyColumn = 0 or SELECT * FROM SomeTable WHERE CAST(SomePrimaryKeyColumn AS int) = @Parameter Characteristics of the issue The behavior is deterministic. It always affects the same primary key column(s) of a composite primary key. It is independent of the SELECT list. It depends on the presence of a parameterized predicate. The actual parameter value does not matter. NULL, DBNull.Value and non-null integer values all show the same behavior. The parameter type is always int. The issue currently affects only few tables. Different tables for different customers. Other columns in the same tables may work correctly. Metadata retrieval mode The issue only occurs when the command is executed using: CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo which is the mode internally used by DbCommandBuilder to derive schema and key information If SchemaOnly is removed, metadata retrieval succeeds. Observed behavior: SchemaOnly | KeyInfo -> GetSchemaTable() returns null KeyInfo only -> Metadata returned correctly Normal execution -> Query executes and returns metadata correctly Therefore the problem appears to be specific to SQL Server's metadata-only derivation path rather than normal query execution. Things we verified Database schema The database schema is identical across customer installations. The issue cannot be correlated with schema differences. Query text / Select list The issue is independent of the projection. For example: SELECT * and SELECT ColumnA show the same behavior. Only the predicate appears to matter. Execution vs metadata retrieval The query executes successfully. Only metadata discovery fails. Plan cache The behavior does not appear to be related to plan cache reuse. The same affected predicate consistently fails during schema discovery. SQL Profiler observations During schema derivation we observed the following with SQL Profiler (re-worked to an example and reformatted to make it more easily readable for a human being): exec sp_executesql N'SET FMTONLY OFF; SET NO_BROWSETABLE ON; SET FMTONLY ON; SELECT SomeColumn FROM SomeTable WHERE PrimaryKeyColumn1 = @PrimaryKeyColumn1 AND PrimaryKeyColumn2 = @PrimaryKeyColumn2 AND PrimaryKeyColumn3 = @PrimaryKeyColumn3 AND PrimaryKeyColumn4 = @PrimaryKeyColumn4 ' ,N'@PrimaryKeyColumn1 int,@PrimaryKeyColumn2 int,@PrimaryKeyColumn3 int,@PrimaryKeyColumn4 int' ,@PrimaryKeyColumn1=NULL,@PrimaryKeyColumn2=NULL,@PrimaryKeyColumn3=NULL,@PrimaryKeyColumn4=NULL The issue occurs only in the metadata-only path used by SchemaOnly | KeyInfo. When the same query is actually executed, metadata and result data are returned correctly. Compatibility level observations The issue is reproducible at: COMPATIBILITY_LEVEL = 160 only. It disappears when the database compatibility level is lowered to: COMPATIBILITY_LEVEL = 150 or smaller. More interestingly, the database can remain at compatibility level 160 while the problem disappears if the query is compiled using compatibility level 150 (or smaller) optimizer behavior: OPTION (USE HINT('QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_150')) With this hint, GetSchemaTable() successfully returns metadata. Additional observations The following query hints also make schema derivation succeed: OPTION (RECOMPILE) and OPTION (OPTIMIZE FOR UNKNOWN) This suggests that the metadata derivation path is sensitive to optimizer behavior, despite the fact that the query is not actually executed. Question Has anyone encountered a SQL Server 2022 / Compatibility Level 160 issue where: GetSchemaTable() returns null the command is executed with SchemaOnly | KeyInfo the underlying query executes normally the problem only occurs for specific parameterized predicates compatibility level 150 or smaller works QUERY_OPTIMIZER_COMPATIBILITY_LEVEL_150 also works while the database remains at level 160 If so, do you have any idea on how to solve this?Anna_HeinemannAug 07, 2026Occasional Reader30Views0likes1CommentCan anyone explain this error and maybe even suggest how to avoid it?
I came across a very strange and unexpected error today, and while I managed to make it "go away" I cannot for the life of me understand why it happened in the first place. And I would like to invite a discussion on what could have caused it, whether it's possible to recognise the situation if it occurs again, and how to prevent it happening in future. I cannot use proprietary data so I can only describe the problem in generic terms I am transferring data between two Azure databases. To do this, I use an external data source. The "from" and "to" tables have the exact same layout, so: Step 1, I create a "work" table by doing a SELECT INTO SELECT TOP 0 [Column1], [Column2], [Column3] INTO [KII].[KIIWorkTable] FROM [dbo].[maintable] Step 2, I add the [$ShardName] column ALTER TABLE [KII].[KIIWorkTable] ADD [$ShardName] NVARCHAR(128) NOT NULL Step 3, read the data from the external data source which also has the maintable with an identical definition INSERT INTO [KII].[KIIWorkTable] EXEC sp_execute_remote [externaldatasource], N'SELECT [Column1], [Column2], [Column3] FROM [dbo].[maintable] Step 4, remove the shard name. I don't need it anymore ALTER TABLE [KII].[KIIWorkTable] DROP COLUMN [$ShardName] So far everything worked perfectly, but now something really bizarre happens Step 5, insert the additional rows: INSERT INTO [dbo].[maintable] ([Column1], [Column2], [Column3]) SELECT [KID].[Column1], [KID].[Column2], [KID].[Column3] FROM [KII].[KIIWorkTable] [KID] And SQL complains that the columns in the insert do not match the columns in the select. Of course in my real world scenario the tables have a lot more columns and the situation is much more complex, but I eventually narrow it down by starting with just one column and slowly trying it again and again, adding more columns as I go on INSERT INTO [dbo].[maintable] ([Column1]) SELECT [KID].[Column1] ..... Works perfectly I keep going until I hit [Column2] and the problem resurfaces I skip [Column2] INSERT INTO [dbo].[maintable] ([Column1], [Column3]) SELECT [KID].[Column1], [KID].[Column3] ...... It works perfectly. It doesn't work if I keep [Column2] between the first and last column, but INSERT INTO [dbo].[maintable] ([Column1], [Column3], [Column2]) SELECT [KID].[Column1], [KID].[Column3], [KID].[Column2] ...... What the..... NOW it works!?!! So obviously there is something not quite right with [Column2]. I look at the table and I see [Column2] is nullable and it contains NULLs in some rows. And I happen to know that it's an integer, and the database design is not ideal, but for our business logic NULL and 0 are interchangeable so I run an update UPDATE [dbo].[maintable] SET [Column2] = 0 WHERE [Column2] IS NULL And now the original statement works as expected. While doing this fixed the problem, I know NULL values aren't the problem. I have done the same thing for several other tables and even this table has other columns that are nullable and that contain nulls, and the same thing doesn't happen for those. I can keep the columns in the order they are defined in the DB schema and the inserts just work, nulls or no nulls. So I'm just wondering what the underlying reason for this could be. Is there anything I can run in t-sql to recognise the scenario if it occurs so I can fix it BEFORE it causes an issue?SolvedrozeboosjeagainAug 04, 2026Copper Contributor60Views0likes2Commentsservices.exe D:\MSSQL\MSSQL17.MSSQLSERVER\MSSQL\Binn\SQLAGENT.EXE ACCESS DENIED
I've been getting failed installs with SQL Server Developer Standard Edition on Windows 2025 Standard edition, error has been: services.exe 1000 QueryOpen D:\MSSQL\MSSQL17.MSSQLSERVER\MSSQL\Binn\sqlceip.exe ACCESS DENIED services.exe 1000 QueryOpen D:\MSSQL\MSSQL17.MSSQLSERVER\MSSQL\Binn\SQLAGENT.EXE ACCESS DENIED I ended up granting local admin rights to the service account I'm using for the SQL Server, whcih allowed the install to complete but still had the same error on sqlceip.exe. I'm logged in to the server the install is running on, as a Domain Admin. The detail file from the setup bootstrap files shows these errors, see below. Any idea why this is happening? 2026-07-26 13:54:31 Slp: Prompting user if they want to retry this action due to the following failure: (01) 2026-07-26 13:54:31 Slp: ---------------------------------------- (01) 2026-07-26 13:54:31 Slp: The following is an exception stack listing the exceptions in outermost to innermost order (01) 2026-07-26 13:54:31 Slp: Inner exceptions are being indented (01) 2026-07-26 13:54:31 Slp: (01) 2026-07-26 13:54:31 Slp: Exception type: Microsoft.SqlServer.Configuration.Sco.ScoException (01) 2026-07-26 13:54:31 Slp: Message: (01) 2026-07-26 13:54:31 Slp: Attempted to perform an unauthorized operation. (01) 2026-07-26 13:54:31 Slp: HResult : 0x84bb0001 (01) 2026-07-26 13:54:31 Slp: FacilityCode : 1211 (4bb) (01) 2026-07-26 13:54:31 Slp: ErrorCode : 1 (0001) (01) 2026-07-26 13:54:31 Slp: Data: (01) 2026-07-26 13:54:31 Slp: DisableRetry = true (01) 2026-07-26 13:54:31 Slp: Inner exception type: System.UnauthorizedAccessException (01) 2026-07-26 13:54:31 Slp: Message: (01) 2026-07-26 13:54:31 Slp: Attempted to perform an unauthorized operation. (01) 2026-07-26 13:54:31 Slp: HResult : 0x80070005 (01) 2026-07-26 13:54:31 Slp: Stack: (01) 2026-07-26 13:54:31 Slp: at Microsoft.SqlServer.Configuration.Sco.Service.StartService(String[] startParams) (01) 2026-07-26 13:54:31 Slp: ---------------------------------------- (01) 2026-07-26 13:54:33 Slp: User has chosen to retry this action (01) 2026-07-26 13:54:33 Slp: Sco: Attempting to close service handle for service SQLSERVERAGENT (01) 2026-07-26 13:54:33 Slp: Sco: Attempting to close SC Manager (01) 2026-07-26 13:54:33 Slp: Sco: Attempting to open SC Manager (01) 2026-07-26 13:54:33 Slp: Sco: Attempting to open service handle for service SQLSERVERAGENT (01) 2026-07-26 13:54:33 Slp: Prompting user if they want to retry this action due to the following failure: (01) 2026-07-26 13:54:33 Slp: ---------------------------------------- (01) 2026-07-26 13:54:33 Slp: The following is an exception stack listing the exceptions in outermost to innermost order (01) 2026-07-26 13:54:33 Slp: Inner exceptions are being indented (01) 2026-07-26 13:54:33 Slp: (01) 2026-07-26 13:54:33 Slp: Exception type: Microsoft.SqlServer.Configuration.Sco.ScoException (01) 2026-07-26 13:54:33 Slp: Message: (01) 2026-07-26 13:54:33 Slp: Attempted to perform an unauthorized operation. (01) 2026-07-26 13:54:33 Slp: HResult : 0x84bb0001 (01) 2026-07-26 13:54:33 Slp: FacilityCode : 1211 (4bb) (01) 2026-07-26 13:54:33 Slp: ErrorCode : 1 (0001) (01) 2026-07-26 13:54:33 Slp: Data: (01) 2026-07-26 13:54:33 Slp: DisableRetry = true (01) 2026-07-26 13:54:33 Slp: Inner exception type: System.UnauthorizedAccessException (01) 2026-07-26 13:54:33 Slp: Message: (01) 2026-07-26 13:54:33 Slp: Attempted to perform an unauthorized operation. (01) 2026-07-26 13:54:33 Slp: HResult : 0x80070005 (01) 2026-07-26 13:54:33 Slp: Stack: (01) 2026-07-26 13:54:33 Slp: at Microsoft.SqlServer.Configuration.Sco.Service.StartService(String[] startParams) (01) 2026-07-26 13:54:33 Slp: ---------------------------------------- (01) 2026-07-26 13:54:33 Slp: User has chosen to retry this action (01) 2026-07-26 13:54:33 Slp: Sco: Attempting to close service handle for service SQLSERVERAGENT (01) 2026-07-26 13:54:33 Slp: Sco: Attempting to close SC Manager (01) 2026-07-26 13:54:33 Slp: Sco: Attempting to open SC Manager (01) 2026-07-26 13:54:33 Slp: Sco: Attempting to open service handle for service SQLSERVERAGENT (01) 2026-07-26 13:54:33 Slp: Prompting user if they want to retry this action due to the following failure: (01) 2026-07-26 13:54:33 Slp: ---------------------------------------- (01) 2026-07-26 13:54:33 Slp: The following is an exception stack listing the exceptions in outermost to innermost order (01) 2026-07-26 13:54:33 Slp: Inner exceptions are being indented (01) 2026-07-26 13:54:33 Slp: (01) 2026-07-26 13:54:33 Slp: Exception type: Microsoft.SqlServer.Configuration.Sco.ScoException (01) 2026-07-26 13:54:33 Slp: Message: (01) 2026-07-26 13:54:33 Slp: Attempted to perform an unauthorized operation. (01) 2026-07-26 13:54:33 Slp: HResult : 0x84bb0001 (01) 2026-07-26 13:54:33 Slp: FacilityCode : 1211 (4bb) (01) 2026-07-26 13:54:33 Slp: ErrorCode : 1 (0001) (01) 2026-07-26 13:54:33 Slp: Data: (01) 2026-07-26 13:54:33 Slp: DisableRetry = true (01) 2026-07-26 13:54:33 Slp: Inner exception type: System.UnauthorizedAccessException (01) 2026-07-26 13:54:33 Slp: Message: (01) 2026-07-26 13:54:33 Slp: Attempted to perform an unauthorized operation. (01) 2026-07-26 13:54:33 Slp: HResult : 0x80070005 (01) 2026-07-26 13:54:33 Slp: Stack: (01) 2026-07-26 13:54:33 Slp: at Microsoft.SqlServer.Configuration.Sco.Service.StartService(String[] startParams) (01) 2026-07-26 13:54:33 Slp: ---------------------------------------- (01) 2026-07-26 13:54:34 Slp: User has chosen to cancel this actionFirmbyteJul 27, 2026Copper Contributor43Views0likes1CommentSQL Server Audit Specification
Is it possible to predicate an Event in a Specification on a Principal Name? The Specification 'Properties' dialogue box seem to indicate filtering on is possible, including 'Object Class', Object Schema', 'Object Name', a but the Syntax doesn't show how.TimSQLJul 21, 2026Copper Contributor58Views0likes2Commentssql server 2019 how to reverse engineer a View using VS or Visio
Hi, I am trying to trace back, and document the lineage of a series of Views that have been created in SQL Server 2019 over many years. Many of the views are quite complex and are Views built or several other Views, Tables and functions. I need to unpick all of the dependencies and logic that has been used in creating these views. I tried to use both Visio and Visual Studios 'Reverse Engineer' tools to do this, but this is not supported for SQL Server 2019 or later. When I connect my database to Visio and select the server and have the connection authenticated, the dialogue box greys out the Views checkbox. I have been told that Visio does not support reverse engineering for SQL Server 2019 or newer. The correct ODBC driver is installed, and I am working with a supported version of Visio (Visio Plan 2) and Visio 2505. Is anyone aware of a workaround to this, and how I might use either Visio and VS to reverse engineer my 50+ views and find all their dependencies and calculations, outputting these in a diagrams that I can give to the engineers to easily understand and unpick? Otherwise, this will take me weeks to do. My company is not keen on using any Third party tools that we would need to install on the server, as these could cause a security issue, but any suggestions of anything that would be light touch would be most welcome. Any help would be much appreciated. Thanks!dosaniaJul 19, 2026Copper Contributor117Views0likes1CommentHow does GitHub Copilot in SSMS 22 handle database context collection before generating a response?
Hello, I am trying to better understand the internal workflow of GitHub Copilot in SSMS 22, especially for database-specific questions. From the product descriptions, it seems that Copilot can use the context of the currently connected database, such as schema, tables, columns, and possibly other metadata, when answering questions or generating T-SQL. However, I could not find clear official documentation about the actual sequence of operations. My main questions are: Before generating a response, does Copilot first collect database context/metadata from the active connection and then send that context to the LLM as grounding information? Or does it first use the LLM to interpret the user’s request, decide what information is needed, and then retrieve database metadata before generating the final answer? In some explanations, I have seen the phrase "Core SQL Copilot Infrastructure", but I cannot find any official documentation for that term. Is this an official component name? If so, what does it specifically refer to in the SSMS Copilot architecture? When Copilot answers schema-related or data-related questions, what information is retrieved automatically from the connected database, and is any SQL executed as part of that process? Is there any official architectural documentation that explains: context collection, prompt grounding, LLM invocation order, and whether query execution can occur before the final response is generated? I am asking because I want to understand the feature from both an architecture and data governance/security perspective. Any clarification from the product team or documentation links would be greatly appreciated. Thank you.ezpz97Jul 18, 2026Copper Contributor88Views2likes2CommentsUnable to install SQL Server 2022 Express (installer glitch + SSMS error)
Hi, I recently purchased a new Lenovo laptop, and I am trying to install Microsoft SQL Server 2022 Express along with SSMS. SSMS installed successfully, but SQL Server installation fails, and sometimes the installer UI glitches or does not load properly. Because of this, I am getting connection errors in SSMS like "server not found" and "error 40". I am not very familiar with technical troubleshooting. Can someone guide me step-by-step in a simple way to install SQL Server correctly? Thank you.Max12Jul 18, 2026Copper Contributor209Views0likes1CommentKerberos double hop delegation on SQL Linked Server fails on AG listener after RC4 disablement
Environment 3 Node- SQL Server 2022 with Availability Group Windows Server 2022 - Linked Server configured with Kerberos delegation (double-hop scenario) - RC4 encryption recently disabled via GPO The Problem After disabling RC4 in the domain (not sure of this root cause), Kerberos delegation through a Linked Server stopped working — but only when connecting via the **AG listener name**. Connecting via the **node name** works fine. I try to migrate my service account to gMSA and I've recreate all SPN and all delegation for the new account, but the issue is the same: Authentication works if the linked server us the node name, if it use the Listener AG name the connection fail with ------------------------------ Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. (Microsoft SQL Server, Error: 18456) Connection Id 6d654295-0538-4837-b900-ff65c9e86ee9 at 2026-04-29 11:59:25Z I Confirmed via Kerberos event logging (Event ID 4769 on DC)** On a healthy request (node name), ticket encryption type is `0x12` (AES256). - Confirmed SPN registration with `setspn -L` - Verified Kerberos events on the DC (4768/4769) - Confirmed forwardable flag (`0x40000000`) is present in ticket options — delegation is active - Confirmed pre-auth and session encryption are both `0x12` (AES256) for the working path set `msDS-SupportedEncryptionTypes = AES128+AES256` on the SQL service account and resetting its password rotete kdc key Are there any additional steps needed on the Linked Server or constrained delegation configuration side after the service account change? Any guidance appreciated. Thanks.GiorgioCaldanaJul 18, 2026Copper Contributor195Views0likes1CommentCannot connect Azure OpenAI Embeddings model to SQL Server 2025
On SQL Server 2025, I am trying to vectorize a table. To set up the ability for SQL Server 2025 to communicate with Azure OpenAI embeddings model, I first created a master key for encryption. CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'Secret'; GO Then I set up a database scoped credential. CREATE DATABASE SCOPED CREDENTIAL [MyAzureOpenAICredential] WITH IDENTITY = 'HTTPEndpointHeaders', SECRET = '{"api-key":"secret"}'; Then I created an external model. CREATE EXTERNAL MODEL AzureOpenAIEmbeddingsModel WITH ( LOCATION = 'https://{secret}-eastus2.cognitiveservices.azure.com/openai/deployments/text-embedding-3-small/embeddings?api-version=2023-05-15', API_FORMAT = 'Azure OpenAI', MODEL_TYPE = EMBEDDINGS, MODEL = 'text-embedding-3-small', CREDENTIAL = [MyAzureOpenAICredential] ); However, when I run this simple script: DECLARE @text NVARCHAR(MAX) = N'SQL Server 2025 enables AI-powered applications'; DECLARE @embedding VECTOR(1536) = AI_GENERATE_EMBEDDINGS(@text USE MODEL AzureOpenAIEmbeddingsModel); I get this error. The database scoped credential 'MyAzureOpenAICredential' cannot be used to invoke an external rest endpoint. I have read through https://learn.microsoft.com/en-us/training/modules/build-ai-solutions-sql-server/4-integrate-ai-models pertaining to this task. As well as SQL Server 2025 docs for creating a model. I have also read SQL Server 2025 docs for creating https://learn.microsoft.com/en-us/sql/t-sql/statements/create-database-scoped-credential-transact-sql?view=sql-server-ver17. I have not found any answers.HassaanFaruqJul 18, 2026Copper Contributor116Views0likes1CommentMigrate SQL 2016 to SQL 2022 - Detail Work Breadown Structre (WBS)
Hi, We’ve started a project to migrate from SQL Server 2016 to SQL Server 2022, and I’m currently preparing a detailed Work Breakdown Structure (WBS). Has anyone in this community gone through a similar migration and been willing to share their project WBS, either in .mpp or Excel format? Regards, Subhasish Roysubhasishroy2025Jul 18, 2026Copper Contributor85Views0likes1Comment
Tags
- sql server81 Topics
- Data Warehouse73 Topics
- Integration Services66 Topics
- sql61 Topics
- Reporting Services47 Topics
- Business Intelligence42 Topics
- Analysis Services33 Topics
- analytics25 Topics
- ssms23 Topics
- Business Apps22 Topics