开发者

Stop showing SQL errors in Visual Studio 2010

How can I stop VS2010 showing errors in .sql files, attached to a project? I don't want to check them at all, just C# code. T开发者_开发技巧he files are used as resources, Build Action set to Content. I'd like to keep .sql extension for syntax coloring purpose.

Regards,


Looks like your question was answered here: https://stackoverflow.com/a/8593877/2798869:


Visual Studio 2010

Tools -> Options -> Text Editor -> Transact-SQL -> IntelliSense

Uncheck "Enable IntelliSense".


Visual Studio 2012 & 2013

Tools -> Options -> Text Editor -> SQL Server Tools -> IntelliSense

Uncheck "Underline errors"


Note that you have to close then re-open any .sql files you may have open.


In VS 2012.

  1. Go to the sql file properties in VS.
  2. Under "Advanced", change the "Build Action" option to "None".

Unfortunately you have to do this for each sql file in the project.

This is what gave me the behavior that I wanted. It not only compiles without errors but shows no sql related build errors.

Update

It is possible to select multiple files in Solution Explorer by using Shift + Click (select the file at the top of the list -> hold down shift -> click the file at the bottom of the list). Once you have selected the group of files, you can then change the Build action to None for all of them at once. (This worked for me in VS2013.)

While you still have to select files per folder you don't have to select each file to set the property.


VS2015

right click in editor of the sql file > Intellisense Enabled

Stop showing SQL errors in Visual Studio 2010


May be a sledge hammer to the problem but I manually deploy my SQL changes and only use them to house the scripts for my builds, so I do not need the functionality provided by SQL Projects.

Open the VS Solution File properties (right-click the solution in VS Solution Explorer and select Properties) and in the left pane select "Configuration Properties" -> "Configuration". In the right-pane you will see the projects in the solution. Un-check these projects to prevent them from building, this will prevent them from showing errors.

Stop showing SQL errors in Visual Studio 2010


Is it possible you have a .cs extension on those files but it's not shown? I added some .sql files to my project and the compiler is not complaining.

Stop showing SQL errors in Visual Studio 2010


Change the type of files to content and then the intellisense will never try and parse the contents of the files.


I just built a test project with one class file .cs and added one .sql file. It automatically set the build type to content. It built fine like John Fraser said in VS2010, so I changed it to compile, and obviously it failed.

This isn't the answer yet but perhaps the next step is to try and create a new solution, and import a few of the files from the original project to try to narrow down the source of the problem. If it builds then it would tell you it is something about the settings in your project/solution. Otherwise it could also be a VS setting.


Steps to stop showing SQL errors in bulk:

  1. Open the SQL project file which has the .sqlproj extension in a text editor.
  2. Find and replace <Build Include= with <None Include=. (This one has the same effect as right-clicking and changing Build Action to None in the solution explorer.)
  3. The SQL errors should disappear in Visual Studio.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜