Suppress some warnings in SQL Server SSDT
Asked Answered
Q

5

34

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?

Quelpart answered 31/5, 2012 at 0:27 Comment(0)
B
11

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

Backdate answered 1/6, 2012 at 17:27 Comment(2)
Does this actually work? because They still show as warnings on msbuild when trying either WarningLevel or nowarn.Chari
@Chari it should be noted that only the numeric part of the warning is what you should use. I'd been trying 'SQL71558' in the warning supporession and it didn't work. However, using '71558' did work. HTHShiner
F
59

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>
Frier answered 27/2, 2014 at 3:5 Comment(4)
@Daniel: True, and that basically set the property in the similar manner in SQLProj File.Frier
@Varun: Didn't work for me, so had to disable through Project Properties, Build, Suppress Transact-SQL warningsIllegalize
It worked great. Though initially it didn't, until I changed the order of the <SuppressTSqlWarnings> i.e., I moved the tag immediately after the <build> tag. My Visual Studio version is 16.10.0. This may help other readers.Linoleum
in your *.sqlproj file: <Build SuppressTSqlWarnings="71502" Include="script.sql" />Marvelofperu
B
11

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

Backdate answered 1/6, 2012 at 17:27 Comment(2)
Does this actually work? because They still show as warnings on msbuild when trying either WarningLevel or nowarn.Chari
@Chari it should be noted that only the numeric part of the warning is what you should use. I'd been trying 'SQL71558' in the warning supporession and it didn't work. However, using '71558' did work. HTHShiner
S
8

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.

Scutari answered 8/8, 2014 at 20:4 Comment(0)
L
3

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.

Lepidopterous answered 4/6, 2014 at 14:25 Comment(0)
B
2

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.

Basement answered 9/2, 2015 at 11:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.