SQL Compare fails to detect most files

I have a local git repository that I am attempting to compare to a sql db.  I chose 'Source Control' as the source and enter the path to the local git repo.  I thin choose 'Database' as the target and select  the server / db I want to compare to and select 'Compare Now'.  The comparison finished successfully and I observe that a huge number (but not all) of the database objects are shown as existing only in the database, although they do all exist in the repo folders.  What might i be doing wrong that is prohibiting these files from being recognized??  Thanks...
Tagged:

Best Answer

  • Alex BAlex B Posts: 1,153 Diamond 4
    Hi @BenjaminDS,

    Unfortunately you will need to have them listed as CREATE PROCEDURE or CREATE OR ALTER PROCEDURE to get SQL Compare to recognize them.

    A relatively easy way to do this is to use a tool such as grepWin (or other grep like tool) which searches the text of files in a directory and can replace - so you could search for ALTER PROCEDURE and replace all occurrences with CREATE OR ALTER PROCEDURE, but changing to that syntax may not be possible for you due to policy or otherwise.

    I hope you are able to give this a try but I can understand if you are not able to continue the evaluation due to your practice.

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?

Answers

  • BenjaminDSBenjaminDS Posts: 4 New member
    sorry, should have specified this is SQL Compare version 13
  • Hi @BenjaminDS,

    I've moved this and your other ticket over to the SQL Compare forum as that is the product in question here.  The other is a duplicate and so I will delete it shortly.

    Regarding your issue - the Source Control option is for databases that are linked to our product SQL Source Control so instead of linking directly to a scripts folder in your repository you would first connect the database using this tool (this page for reference on linking the database to Git).

    If you did not want to do that, you would want to clone a local copy and use the Scripts folder option.

    Also, if you have created the scripts yourself rather than scripting them out with SQL Compare or SQL Source Control, they may be in a form that our tools aren't able to parse correctly - or possibly if you are using ALTER instead of state based CREATE statements and other non-schema statements then those will not be included either.

    I hope that helps clarify how things should work!

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
  • BenjaminDSBenjaminDS Posts: 4 New member
    Hi Alex,

    Thanks so much for your response!  We do have a standard practice of keeping individual stored procedure files in git in a format that does indeed use the 'alter procedure' syntax.  Some preliminary testing indicates that this may well be what is happening.  So, is there anything I can do to work with these files??  I noticed there is a 'change alter to drop and create' option  in the SQL compare UI, but this appears to be just a setting for the scripts that are generated by SQL Compare.  Is there any way to do something similar in the compare itself?  rewriting all of out procedure definitions in source control may be a bit of a non-starter...
    Thanks again for your help!
  • BenjaminDSBenjaminDS Posts: 4 New member
    Hello again Alex,

    Yeah, that's basically what I ended up doing.  I have a python script acting as a 'pre-processor' now that converts all of the instances of the the 'alter proc'  syntax in the files to 'create proc' and it looks like the compare is working now, so I don't think this is a deal killer just yet!  Thanks again for all your help!
Sign In or Register to comment.