Suppress Database Project errors and warnings in visual studio 2010

跟風遠走 提交于 2020-06-24 18:14:10

问题


I have an Database project in my application and want to suppress the errors/warnings thrown by this project. .first of all is it possible ?

I think I was not clear with my question, by suppressing I meant that when I build my Solution, the errors(which actually are not errors) are shown in the error list, I just want that all Database project related errors should not be shown in the error list.

I am using VS2010.

thanks in advance


回答1:


To surppress a specific warning, go to project properties -> Build.

Type in the warning numbers in comma delimited format in field "Suppress Transact-SQL warnings:".




回答2:


What i tried and worked for me was select the file in the project: i.e.: projectDatabase\ddl\table_name.sql and on the file properties window set Build Action : None.

In build it doesn't look in this files for errors or warnings.

Little late but hope that help.




回答3:


Just had this problem in Visual Studio 2015.

Halfway along the header of the Error List panel, there is a (unnamed) dropdown with values 'Build + Intellisense', 'Build Only', 'Intellisense Only'. Mine was set to 'Build + Intellisense'. Changing it to 'Build Only' got rid of all the (200+) errors.




回答4:


better late than never:

Options -> Database Tools -> Databse Errors and Warnings -> set the maximum at 0 and from now on the error window will have a single entry that will say something like

Error 1 The maximum number of 0 errors has been reached. 76 total errors, 0 total warnings, and 0 total messages were encountered.

--EDIT-- FROM THE COMMENT BELOW...VERY HELPFUL
In VS 11 it appears this option has moved to Tools > Options > SQL Server Tools > General




回答5:


You could remove the build/deploy of the project from your solution configuration. That way VS would not try to build the database project at all.

Of course any changes in the database project would be ignored.

To change or create a new solution file right click on the solution node in Solution Explorer and select properties. In that dialogue the configuration node (under Configuration Properties) tab and click configuration manager.

This allows you create new configurations and edit existing ones, and each configuration is mapped on to a project configuration (to add a new one select <new> on the active solution drop down).

Of course, the better approach is to fix the errors.




回答6:


My workaround (in VS2019) was:

1) Set Build Action to None for this script. => To avoid error messages 2) Create a PostDeployment script (if not present) 3) Add the line :r .\Path_script\script_name.sql => To execute the script when publishing (Add a drop statement before if necessary)

Activate SQLCMD Mode in menu SQL->Execution settings -> SQLCMD Mode

Hope this help.




回答7:


Going back to the accepted answer for Warnings and Visual Studio 2019:

1) Right click on the database project and select properties Database solution

2) Under "Build" and "Suppress Transact-SQL warnings:" enter the SQL warning number you want to suppress, ex: SQL71502 you enter 71502. You can enter multiple warning suppression codes in a coma delimiter way. Example of suppression codes for unresolved reference to object

3) Save your solution and warning should go away. You might have multiple warning codes to enter in order for the warnings to 0 out.




回答8:


In VS 2015, you can suppress the warning 2 ways.

Project Level

I don't suggest this because I only like suppressing warnings if I know exactly what I am suppressing. In C#, for example, we can use SuppressMessageAttribute at a very granular level.

Nonetheless, here is how:

Right click database project > Properties > Build > Suppress Transact-SQL Warnings:

Enter the warnings you want to suppress such as 4151.

File Level

I prefer/suggest this option because it is more granular compared to above option.

Right click file in solution explorer1 > Properties > Suppress T-SQL Warnings

Enter the warnings you want to suppress such as 4151.


1. You must right click the file node in solution explorer. You will get a different options if you right click the file in editor.

There may exist another way but I only know of these 2 ways thus far.




回答9:


In Visual studio 2017, you can do the following: Go to tools --> options --> SQL server tools --> Under Errors & Warnings, set “Maximum no. of errors & warnings….” as 1.




回答10:


  1. You may Exclude that project while build by right click on that project and choose 'Exclude Project'if Windows App. 'Unload Project' if Web App.

  2. To show/Hide Error list

    • Go to Tools > Options

    • Expand Projects and Solutions

    • Choose General.

    • On the right hand side, First check box is 'Always show Error List if build finishes with errors'



来源:https://stackoverflow.com/questions/5685139/suppress-database-project-errors-and-warnings-in-visual-studio-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!