One of our customers running SQL standard edition 2022 wanted to explore setting their database's compatibility level to 2022; but when they do this, at least one of our queries fails to return metadata. So they have to keep the compatibility level at 2019 to avoid the problem. The SQL looks like this:
------------------- start SQL:
exec sp_executesql
N' SET FMTONLY OFF; SET NO_BROWSETABLE ON; SET FMTONLY ON;
select (some columns) from (a table)
where PropertyId=@propertyid and TransKey=@transkey and TransSrc=@transsrc',
N'@propertyid varchar(3), @transkey varchar(6), @transsrc varchar(7)',
@propertyid='001', @transkey='2222.2', @transsrc='XMLTest'
-------------------end of SQL
When troubleshooting in SSMS [at compatibility level 2022], we're getting a response of "Commands completed successfully." (along with the completion time); but no columns (column headers) appear like they normally would.
Here's the weird part:
Then when we change the @transkey parameter's type to nvarchar, it works - even though the column's type is varchar. It also works if we set the other two parameters' types to nvarchar and keep the @transkey parameter's type as varchar. Except for the select statement, the SQL is auto-generated by a .NET Framework 4.8 DataTable object. What the heck is going on here? Thanks for your help!