Filtering Out Object With Underscore

eyeoniteyeonit Posts: 5
edited November 13, 2015 12:41PM in SQL Compare 11
Hello there,

I've got a question. It seems an underscore in the name is throwing off the filter within SQL Compare Pro 11. Is there a way of filtering out a stored procedure with the name of _NameOfStoreProcedure? We've got a handful of objects with a leading underscore in the name and I'd like to filter out a few of them.

Any help would be much appreciated. I've searched high and low and only found these posts. I tried the second link but it didn't work.

https://forums.red-gate.com/viewtopic.php?f=177&t=78977&p=139684&hilit=underscore#p139684

https://forums.red-gate.com/viewtopic.php?t=21805

If I'm missing something I do apologize.

Comments

  • We changed the behaviour of SQL Compare with underscores in filters in version 11.2 of SQL Compare - the release notes here describe the changes in detail. Hopefully updating to the latest version, and possibly editing any filters you've got saved in project files, should fix your problem.
    Development Lead
    Redgate Software
  • Mike Upton wrote:
    We changed the behaviour of SQL Compare with underscores in filters in version 11.2 of SQL Compare - the release notes here describe the changes in detail. Hopefully updating to the latest version, and possibly editing any filters you've got saved in project files, should fix your problem.


    Hello Mike,

    I'm currently on version 11.3.0.7. I've tried everything and can't get some stored procedures excluded. They are with an underscore like this. _NameOfStoredProcedure. I'm currently using the operator LIKE.

    Here's the XML.

    <StoredProcedure version="1">
    <Include>False</Include>
    <Expression>((@NAME LIKE '_NameOfStoredProcedure') AND (@NAME LIKE '_NameOfStoredProcedure2'))</Expression>
  • You'll need to escape the _ character in square brackets - as of version 11.2, the UI will do that for you automatically - I didn't realise you were manually editing the filter XML. Also, shouldn't that be an OR expression rather than an AND - your current expression matches on the proc name being both _NameOfStoredProcedure and at the same time _NameOfStoredProcedure2.

    This is probably what you want:
    &lt;StoredProcedure version="1"&gt;
    &lt;Include&gt;False&lt;/Include&gt;
    &lt;Expression&gt;((@NAME LIKE '&#91;_&#93;NameOfStoredProcedure') OR (@NAME LIKE '&#91;_&#93;NameOfStoredProcedure2'))&lt;/Expression&gt;
    
    Development Lead
    Redgate Software
  • Hello again,

    I kept trying different things and finally got it working!!! What I did was modify the filter and used EQUAL instead of LIKE.

    Thank for you the quick replies. I really appreciate it.


    Here's what the final XML looks like.

    <Include>False</Include>
    <Expression>(@NAME = '_NameOfStoredProcedure') OR (@NAME = '_NameOfStoredProcedure2')</Expression>
  • Mike Upton wrote:
    You'll need to escape the _ character in square brackets - as of version 11.2, the UI will do that for you automatically - I didn't realise you were manually editing the filter XML. Also, shouldn't that be an OR expression rather than an AND - your current expression matches on the proc name being both _NameOfStoredProcedure and at the same time _NameOfStoredProcedure2.

    This is probably what you want:
    &lt;StoredProcedure version="1"&gt;
    &lt;Include&gt;False&lt;/Include&gt;
    &lt;Expression&gt;((@NAME LIKE '&#91;_&#93;NameOfStoredProcedure') OR (@NAME LIKE '&#91;_&#93;NameOfStoredProcedure2'))&lt;/Expression&gt;
    

    Thanks Mike!!

    I actually wasn't editing the XML. I'm using the UI and was just referencing the XML so others could see what it looked like.

    It's working now. Thanks again.
Sign In or Register to comment.