How to check the ANSI Compatibility of SQL Server Queries? – Interview Question of the Week #221

Question: How do you check ANSI compatibility of SQL Server queries? SET FIPS_FLAGGER can flag constructs against the historical FIPS 127-2 standard. It doesn’t certify that a query will behave identically in another database product.

A round wooden piece fits its matching opening while other shapes need different openings

This question surprised me during a Comprehensive Database Performance Health Check. I had used this feature when moving work between relational database systems, but hadn’t heard it as an interview question.

The checker offers ENTRY, INTERMEDIATE and FULL levels. Its FIPS 127-2 foundation comes from SQL-92. That is a historical language standard, not the latest SQL standard or a check of today’s product-specific behavior.

Try the original demonstration

The sample uses AdventureWorks and its DatabaseLog table. Select the corresponding database installed on your server; here it is AdventureWorks2025.

USE AdventureWorks2025;
GO
SET FIPS_FLAGGER 'FULL';
GO
SELECT TOP 5 *
FROM [dbo].[DatabaseLog];
GO
SET FIPS_FLAGGER OFF;
GO
Complete SQL and FIPS warnings
Actual SSMS Messages output, SET and TOP warnings and five affected rows.

Read the Messages tab for standards warnings. TOP and bracket-delimited identifiers are SQL Server extensions, so this is deliberately not a portable example. The query still runs: the setting reports warnings, rather than converting the statement into portable SQL.

Use separate batches as shown. FIPS_FLAGGER acts at parse time, so placing OFF later in the same batch can change which text is checked. Restore OFF before continuing ordinary work.

A clean warning list is only the start of a portability review. Test the query on the intended target product with the same data, including nulls and boundary values. Compare the values and data types it returns. SQL Server compatibility levels don’t turn T-SQL into another product’s dialect.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

Compatibility Level, SQL Scripts, SQL Server
Previous Post
Does ARITHABORT Setting Negatively Impact SQL Server Performance? – Interview Question of the Week #220
Next Post
How I Know If I am DBOWNER or Not in SQL Server? – Interview Question of the Week #222

Related Posts

1 Comment. Leave new

  • I tried this and I’m a little confused by what it’s supposed to do. I have a query using CROSS APPLY and UNPIVOT operators (MS SQL Server) and with SET FIPS_FLAGGER ‘FULL’ these clauses don’t give a warning? I thought these were not ANSI SQL-92 standard commands?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.