Code: Select all
SELECT
, company_name
, company_DBA_name
, preferred_comm_type
, company_website
FROM
COMPANY C
Code: Select all
SELECT
, @company_name = isnull(@company_name, company_name)
, @company_DBA_name = isnull(@company_DBA_name, company_DBA_name)
, @preferred_comm_type = isnull(@preferred_comm_type, preferred_comm_type)
, @company_website = isnull(@company_website, company_website)
FROM
COMPANY C
\1@\2 = isnull\(@\2, \2\) but it's the search criteria that's kicking me in the bajingo.
Using POSIX style reg exp, I am attempting to find company_name, company_dba_name and the rest of the column names. I know syntactically the above SQL is invalid but I thought if the first line of it started with a comma, then I would know column names are in lines that look like , 3 spaces and then the column name. Column names will contain at least one letter and potentially underscores and digits. For the sake of brevity, the comma and spaces will be omitted in my following examples.
[[:alpha:]]+ will get the words to highlight. So I'm a third of the way there.
[[:alpha:]|[_]]+ This won't find anything
[[:alpha:]]|[_]+ This will find each piece of the word (excluding the digits) but not the whole word (which I'll need come replacement time)
[[:alpha:]]|[_]|[[:digit:]]+ This gets me everything but only one piece at a time.
Rereading the help on regular expressions I see that the or matches either the expression on the right or left so that led me to
[[:alpha:]]+|[_]+|[[:digit:]]+ which is back to highlighting the entire word, the underscore or the digit but not at the same time, only one element at a time. At this point I also chose to put the whitespace back in and saw that doing that wasn't quite what I wanted.
, [[:alpha:]]+|[_]+|[[:digit:]]+ starts off great --- it grabs the comma the space and first word, then it catches either the underscore or the digits or the next instance of comma 3xSpace word. I think I need to be able to tell it to group the OR'd stuff together but I'm just not seeing how to do it.
What am I missing? Besides the time to sit and read the Mastering Regular Expressions book? I've hacked together a macro that works better than manually doing it but a solution would make me feel better. Not as good as having seen it myself but better than nothing.
Thanks.