Results 1 to 15 of 15
  1. #1
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6

    Unanswered: cleaning junk characters in .sql files programatically

    Back Story...

    i am building a new deployment routine for one of our products using NANT (.net version of ANT). I takes all of .sql files out of vault for all non table objects and concatenates them into larger .sql files with IF EXISTS .... DROP ... GO CREATE statements which will then be fired off by osql batch files that will log the errors.

    Problem...

    When I open the resulting files in notepad I have junk characters (microsoft OEM stuff) in some of my object definitions which you do not see in the QA or if you opnen the file in Vault. I need to get this stuff out of there and I do not want to write a bunch of filesystem code to do it because I need this tested and ready by Friday COB. I know I can solve this by opening the problematic files in ultraedit and saving them one by one but I do have that kind of time.

    Any ideas?

    It's going to be a long couple of days.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    What about opening the file in an application that correctly interprets the characters (Word, Wordpad) and then saving in a text-only format?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    Sean ... UltraEdit will allow you to search and replace in files ... but you already knew that. You could have UE search for an identified hex charter and replace with hex 20 (space).

    -- This is all just a Figment of my Imagination --

  4. #4
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    no i did not know that. i just downloaded ultra edit. thanks guys.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    if you want help with ultraedit, i'm a power user

    started using it at this one contract i was on, and eventually purchased a license for my own use at home

    and of course real power users use key combos, like ...

    alt-A, I (insert snippet of code)
    alt-T, G (trim trailing spaces)
    alt-W, Y (synchronized scrolling)
    ctrl-H (toggle hex)
    alt-F,R,S (sort using current parameters)
    ctrl-- [control-minus] (hide lines)
    alt-C (column mode)

    especially that last one, i can't tell you how many times i need to paste some data over several rows, but only over part of each row...

    and regular expressions -- great for search/replace where you're looking for a pattern
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    The license fee is cheap considering all the goodies Ian put into the software!

    Rudy ... I have never used the synchronized scrolling feature ... would that be like when you have pulled two files for a line by line comparison?

    And Amen to the column mode! Probably one of the greatest things since sliced bread!

    -- This is all just a Figment of my Imagination --

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by tomh53
    Rudy ... I have never used the synchronized scrolling feature ... would that be like when you have pulled two files for a line by line comparison?
    yes

    i believe there's an actual file compare function, but the few times i tried it, i didn't understand how to use it

    i get by just fine eyeballing the code after tiling the two file tabs horizontally
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  8. #8
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Oh, I think it is DEFINITELY worthwhile to learn to use UltraCompare! I love column mode, but this beats the pants off of it, several times a week for me.

    -PatP

  9. #9
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Thank you.

    Just downloaded it and it looks very cool
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  10. #10
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    Don't forget to grab the sql wordfile and add it to the wordfile.txt file. That allows UE to highlight key words.

    -- This is all just a Figment of my Imagination --

  11. #11
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    oh yeah, wordfiles!

    extremely juicy -- i use them for html, coldfusion, etc.
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  12. #12
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    One of these days I need to either figure out how to get the incorporated "Artistic Style Formatter" to work on Transact-SQL, or I'll have to write my own. I'm leaning toward a "roll your own" approach as an EXE filter using both INI files (to allow different formats for different projects) and command line parameters too. This would have lots of practical uses (such as cleaning up SQL-DMO generated scripts) outside of editing, but it would also be usable within Ultra-Edit.

    Hmmm... I feel a project coming on (like I have time for that right now)!

    -PatP

  13. #13
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by Pat Phelan
    One of these days I need to either figure out how to get the incorporated "Artistic Style Formatter" to work on Transact-SQL, or I'll have to write my own. I'm leaning toward a "roll your own" approach as an EXE filter using both INI files (to allow different formats for different projects) and command line parameters too. This would have lots of practical uses (such as cleaning up SQL-DMO generated scripts) outside of editing, but it would also be usable within Ultra-Edit.
    Gosh Pat - I'll bet all the girls are swooning round you, you old dog
    Testimonial:
    pootle flump
    ur codings are working excelent.

  14. #14
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Quote Originally Posted by pootle flump
    Gosh Pat - I'll bet all the girls are swooning round you, you old dog
    I must have "missed a meeting" somewhere.

    Yeah, I'm a real geek... What can I say?

    -PatP

  15. #15
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Pat is one hoopy frood who really knows where his towel is.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •