Rule to ignore text at top of files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stephenb
    New User
    • Feb 2013
    • 2

    Rule to ignore text at top of files

    I am trying to set up a filter to compare two SQL script files. These files may have different text in them before the CREATE PROC(or FUNCTION etc) statement.

    How can I set up a filter to ignore all text from the start of the file before the word "CREATE"?
  • Aaron
    Team Scooter
    • Oct 2007
    • 16000

    #2
    Hello,

    You can customize the SQL file format with a new grammar element, that matches on your text section.

    *Update: This is done from the Tools menu -> File Formats dialog, select the SQL text format.

    You can then mark this element as Unimportant in the Session Settings for the specific session, or the default session settings.

    We have a KB article with video, here:
    http://www.scootersoftware.com/suppo..._unimportantv3

    If you have any questions. Please let us know. You can email us at [email protected] with
    - A link to this forum thread for our reference
    - Your BCSupport.zip from the Help menu -> Support dialog; Export
    - A pair of sample files
    - A full screen screenshot showing the text you wish to mark as unimportant.
    Last edited by Aaron; 13-Feb-2013, 10:09 AM. Reason: Update
    Aaron P Scooter Software

    Comment

    • stephenb
      New User
      • Feb 2013
      • 2

      #3
      Thaks for the prompt response.

      There are two issues with the suggested solution:

      1. This does not apply to version 2. The solution is for version 3 that is not our company supplied version.

      2. I downloaded and installed a portable version of v3. It still does not appear to satisfy my needs. If I create a gammar rule using the Lines option it allows me to define a text rule for the start 9 or line 1) then a number of lines to ignore but i need it the other way around. I need to ignore from line 1 a vaiable number of lines to the word "CREATE".

      Also there may be a different number of lines at the top in either file in the compare eg.

      In file 1 I might have:

      USE [database]
      GO
      DROP FUNCTION [dbo].[fnSomefunction]
      GO
      SET ANSI_NULLS ON
      GO
      SET QUOTED_IDENTIFIER ON
      GO
      CREATE FUNCTION fnSomefunction


      then in file 2 I might have:

      if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fnSomefunction]') and xtype in (N'FN', N'IF', N'TF'))
      drop function [dbo].[fnSomefunction]
      GO
      SET QUOTED_IDENTIFIER ON
      GO
      SET ANSI_NULLS ON
      GO
      CREATE FUNCTION fnSomefunction


      so I want to exclude all lines from both files up to the line beginning with CREATE

      Comment

      • Aaron
        Team Scooter
        • Oct 2007
        • 16000

        #4
        Hello,

        Sorry, I did not notice this was in the BC2 forum. For BC2, you can have similar definitions provided in the Tools menu -> Options Dialog, Rules section, select a specific Rule, then in the Importance tab define either "Unimportant Text" (Unimportant) or "String literals" (Important).

        The Page Headers type has the same limitations as BC3 (though, moreso, as it is Line 1 to Line X only). We do not currently support an inverse of this definition.

        To work around this, I would recommend creating an External Conversion which could trim the header out of your file for the compare. This would leave you with a temporary file, missing the header, and leave only the information you want to compare behind. Alternatively, the conversion could add an extra line of text for Line 1 and the line immediately before CREATE, then have a custom Delimited grammar type that matches on these newly inserted comments and everything between them.

        An external conversion is a call to a command line utility or script that you can plug into BC2 or BC3, which takes in the file as input and outputs a temporary text file for comparison.

        We have a BC2 KB article on the subject here:
        http://www.scootersoftware.com/suppo...=kb_conversion
        And a BC3 article (using RESX as the sample) here:
        http://www.scootersoftware.com/suppo...rnalconversion

        I'll also add this use case to our Customer Wishlist as a potential feature enhancement for our grammar support.
        Aaron P Scooter Software

        Comment

        Working...