Macro to change the case of SQL keywords.
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Macro to change the case of SQL keywords.
Does any one have a macro to change the SQL keywords to UPPER case?
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
You can do this wih a single regular expression search and replace:
This assumes you are using Posix regular expression syntax:
You can get a complete list fom the documentation for your brand of SQL server.Find what: \<(select|insert|update|from|where|and|order by|left|right|outer|inner|join|...)\>
Replace with: \U\1
[X] Regular expression
Replace All
This assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
Thank you Ben!
While the solution works for most of the times, I have following scenarios
1. what if I have a variable like lv_select
to solve the above problem i I prefix and suffix a space in the FIND WHAT then,
1. what if the keyword is the first or last word in the line ?
One more question,
what is Posix?
While the solution works for most of the times, I have following scenarios
1. what if I have a variable like lv_select
to solve the above problem i I prefix and suffix a space in the FIND WHAT then,
1. what if the keyword is the first or last word in the line ?
One more question,
what is Posix?
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Try it. The regular expression I suggested doesn't match lv_select. That's what the \< and \> are for. \< makes the regular expression match a string only if it begins at the beginning of a word; \> makes it match a string only if it ends at the end of a word. Look in TextPad's help under Reference Information | Regular Expressions.
In this context Posix is just a syntax for regular expressions. It differs from TextPad's default in whether the characters (, ), {, } and | are preceded with a backslash to make them literal (Posix) or to make them special (default). See TextPad's help under How to... | Find and Replace Text | Use Regular Expressions.
In this context Posix is just a syntax for regular expressions. It differs from TextPad's default in whether the characters (, ), {, } and | are preceded with a backslash to make them literal (Posix) or to make them special (default). See TextPad's help under How to... | Find and Replace Text | Use Regular Expressions.
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
Tip of the hat to Ben as well for this. One of my current tasks is to get this new TSQL code base into a consistent format and while heavy use of ctrl-U has been handy,
\<(select|insert|update|from|where|and|order by|left|right|outer|inner|join|as|with|if|begin|end|or|between|exists|in|cross|all|any|like|not|null|create|drop|prodcedure|function|table|trigger|view|alter|exec|execute|add|asc|desc|delete|return|cursor|declare|into|is|set|output|rank|grant|union|use|values|case|when|top)\>
is far more efficient.
That is a S&R that is getting dropped into my clib book of handy things.
\<(select|insert|update|from|where|and|order by|left|right|outer|inner|join|as|with|if|begin|end|or|between|exists|in|cross|all|any|like|not|null|create|drop|prodcedure|function|table|trigger|view|alter|exec|execute|add|asc|desc|delete|return|cursor|declare|into|is|set|output|rank|grant|union|use|values|case|when|top)\>
is far more efficient.
That is a S&R that is getting dropped into my clib book of handy things.
I choose to fight with a sack of angry cats.