SQL71558 The object reference differs only by case

TomAgTomAg Posts: 1 New member
Hi,
I am using Visual Studio 2022 with SQL Prompt. 
I have multiple errors in Visual studio build about case difference.

example:
I have a stored procedure that does  SELECT bankid FROM [db1].[dbo].[table1]
Error SQL71558: The object reference [db1].[dbo].[table1].[bankid] differs only by case from the object definition  
[db1].[dbo].[table1].[BankID]

The build is basically saying to do SELECT BankID FROM [db1].[dbo].[table1]
because in table1 the column is BankID. 
Build fails. And I have multiple errors like this. 
I know I can cancel in the project properties "validate casing on identifiers". That is not what I am looking for. 
I want SQL promt to change the stored procedure automatically in all solution. 
Is there a way? 
I can't seem to find it. 
Tagged:

Answers

  • Hi @TomAg

     

    Thank you for reaching out on the Redgate forums regarding your casing concern in Visual Studio.

     

    SQL Prompt should be able to help with casing formatting when you are working with an open .SQL file with active connection to your database.

     

    In your formatting style there is a section in Global > Casing to set how casing is applied for keywords, functions, data types & variables.

    Setting these as expected and then formatting your code should start to bring it in line with the formatting of code in your database.

     Once you've set your style as active, it can be applied by running format code in Extensions > SQL Prompt > Format code

     


    If you have an active SQL Toolbelt/Toolbelt Essentials subscription, you can also bulk update SQL files through Extensions > SQL Prompt > Bulk Actions > Format SQL Files. This will quickly apply your SQL Formatting to multiple files at once.

    https://documentation.red-gate.com/sp/features-available-only-in-sql-toolbelt-essentials-and-sql-toolbelt/bulk-operations

    Jon Kirkwood | Technical Support Engineer | Redgate Software
  • I am new to SQL Prompt and formatting and trying to do the formatting on several scripts. The problem I have is the scripts are part of a SQL Database project in Visual Studio 2022 when running format it does not change the case of fields or table names. However when I run against the same script in SSMS the case of the fields and tables are updated. I am now having to copy the scripts into SSMS to format and then copy back to Visual Studio, is there something I am missing in Visual Studio.
Sign In or Register to comment.