Book a Demo

Author Topic: Format SQL queries for usage in VBScript  (Read 2920 times)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Format SQL queries for usage in VBScript
« on: September 29, 2020, 11:03:13 pm »
When I write script I tend to format the SQL Queries I use a certain way.

I go from

Code: [Select]
select o.Object_ID from t_object o
where o.Stereotype = 'Pool'
and o.Name <> 'Aquafin'
and not exists
(select s.Object_ID from t_object s where s.ParentID = o.Object_ID)
and o.Package_ID in (123)

to

Code: [Select]
"select o.Object_ID from t_object o                                     " & vbNewLine & _
" where o.Stereotype = 'Pool'                                           " & vbNewLine & _
" and o.Name <> 'Aquafin'                                               " & vbNewLine & _
" and not exists                                                        " & vbNewLine & _
" (select s.Object_ID from t_object s where s.ParentID = o.Object_ID)   " & vbNewLine & _
" and o.Package_ID in (123)                                             "

I got bored of having to do that manually in Notepad++ each time, so I wrote a little tool that does this formatting for me:

https://github.com/GeertBellekens/TextHelper/releases/tag/v1.0

I guess it's a pretty niche type of thing, but if you happen to have the same itch, enjoy ;D

Geert