A small free .Net and JS library (with demo UI, command-line bulk formatter, SSMS/VS add-in, notepad++ plugin, winmerge plugin, and demo webpage) for reformatting and coloring T-SQL code to the user's preferences.
About the following formatted sql I have 3 issues/questions:
The formatter generates a line feed before and after "union all". How can I avoid this?
Is it possible to have "create or replace" in one line?
A possibility to filter the backticks (`) would be very cool. Or is this possible somehow?
create
or REPLACE view `v_auftrag` as
select 'Umzug' as `typ`,
`x`.`datum` as `datum`,
`x`.`id` as `id`,
`x`.`team_user_id` as `team_user_id`,
`x`.`datum_von` as `datum_von`,
ifnull(`x`.`datum_bis`, `x`.`datum_von`) as `datum_bis`
from `umzug` `x`
having (
`x`.`id` = (
select max(`umzug`.`id`)
from `umzug`
where (
(`umzug`.`datum_von` is not null)
and (`umzug`.`datum_von` = `x`.`datum_von`)
and (`umzug`.`team_user_id` = `x`.`team_user_id`)
)
)
)
union all
select 'Entsorgung' as `typ`,
`x`.`datum` as `datum`,
`x`.`id` as `id`,
`x`.`team_user_id` as `team_user_id`,
`x`.`datum_von` as `datum_von`,
ifnull(`x`.`datum_bis`, `x`.`datum_von`) as `datum_bis`
from `entsorgung` `x`
where (
(
not (
exists (
select 1
from `umzug`
where (
(`umzug`.`datum_von` is not null)
and (ifnull(`umzug`.`team_user_id`, 0) = ifnull(`x`.`team_user_id`, 0))
and (`umzug`.`datum_von` = `x`.`datum_von`)
)
)
)
)
and (`x`.`datum_von` is not null)
)
order by 2 desc,
3 desc
I use the batch version within DBeaver/MariaDB.
About the following formatted sql I have 3 issues/questions: