How can we help you today? How can we help you today?

Filtered Indexes are not compared properly

I am using SQL Server 2022. I have my database changes in version control using a Scripts folder created by SQL Compare (15.4.17.28422). 

One of my tables has two filtered indexes.  When I view the .sql file for the table in my scripts folder, the WHERE clause is present. When I use SQL Compare to compare the folder to the database table, it detects a difference in the index. The left side of the compare (from the scripts folder) does not show the WHERE clause in the SQL Compare summary view but the right side (DB side) does. 

If I deploy it, it removes the filter from the index. 

Help!

Toni Feltman
0

Comments

2 comments

  • Eddie Davis

    Hi Toni,

    Would it be possible to obtain a copy of the DDL for the table with the two filtered indexes?  Also copy of the scripts file for the table from your scripts folder?  


    Just to confirm, the scripts folder is the source and the deployment target is the database?  As the deployment process when you deploy will remove the where clause, as the deployment will modify the database in this scenario so it matches the source scripts folder.
     
    The scripts folder, was it created from a different database?  If yes, does the source database include the filtered indexes with the where clause?

     

    Many Thanks

    Eddie

    Eddie Davis
    0
  • Toni Feltman

    To simplify:
    1. Our scripts folder is the source. It does contain the filter on the indexes. 

    2. The SQL Server DB is the destination. The table in the DB contains the filter on the indexes too.

    3. When I run SQL Compare, it says that the source file does not contain the filter. 

    4. I thought maybe it was a visual thing and that SQL Compare didn't really think there was a difference, so I deployed. When I did, the filter was removed in the DB. 

    I will send you a .zip file with the file from our scripts folder AND the DDL from SSMS. Where can I send it. 

    Also, if you want to hop on a Teams call, I can show you. Thanks!

    Toni Feltman
    0

Add comment

Please sign in to leave a comment.