質問

In SQL Server Data Tools, I would like to suppress some, but not all, occurrences of SQL71502 ("--- has an unresolved reference to object ---"). I know I can suppress through Project Properties, Build, Suppress Transact-SQL warnings, but this will globally suppress. Can this be done?

役に立ちましたか?

解決

You weren't clear on what would determine which 71502 messages would be suppressed and which ones wouldn't but based on my own understanding and research I think the answer is the same. In short, no.

You can suppress all warnings, or warnings based on a specific code ( 71502 ) but that is as granular as it gets.

http://msdn.microsoft.com/en-us/library/hh272681(v=VS.103).aspx

This link talks about promoting warning to errors but also demonstrates how the suppress filter is used - which based on your question you probably already know.

http://social.msdn.microsoft.com/Forums/is/ssdt/thread/9b698de1-9f6d-4e51-8c73-93c57355e768

他のヒント

You can suppress it at individual file level which contains the code generating the warning if you want. Something like this.

<Build Include="Stored Procedures\X.sql">
    <SuppressTSqlWarnings>71502</SuppressTSqlWarnings>
</Build>

It sounds like you're trying to do this at the object/file level, like a sproc.

If this is the level of granularity you're wanting, then, with the project open, select the object and in the properties is an option to Suppress TSql Warnings, enter 71502 and that should do it.

Other warnings for the object will still be raised - as will 71502 warnings in other objects.

If the warnings are originating from Stored Procedures, you could set the Suppress on specific sprocs by adding the number portion of the warning (comma delimited if you want more) to the Suppress TSql Warning section in the sproc properties.

As already stated, it is possible on an object level to ignore all occurences of a warning/error. If you want to only ignore a certain occurence of the warning within an object that is not possible.

I found a workaround that might also help you.

In my case I am referencing a table within a stored procedure that is created by a "select * into ..." statement and Visual Studio cannot handle any following reference on this new table and I get lots of SQL71502 warnings. To trick VS I created at the top of my SP the following:

IF 1=2 CREATE mytable(...)

Doing so VS can validate all refernces but because the condition of the if clause is always false there is no negative influence on my SP. Just keep in mind to update the CREATE statement if necessary.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top