dbquery, MS variables

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
hoangvo81
Pro Scripter
Posts: 69
Joined: Tue Feb 07, 2012 8:02 pm

dbquery, MS variables

Post by hoangvo81 » Wed Aug 28, 2013 12:20 am

Hi,

More so an FYI than anything since I couldnt figure out why until I retype it as a question on this forum.

Code: Select all

let>holder='abc','def','ghi'
let>sql=select * from table1 where field1 like 'Test%' and field2 in (%holder%)
mdl>sql
you cannot use like 'Test%' or '%Test%' and use an MS variable holding your values in same line in MS' Let statement.
The above statement should show:
select * from table1 where field1 like 'Test%' and field2 in (%holder%)
this is sent to dbquery and causes an error in the sql statement

Code: Select all

let>holder='abc','def','ghi'
let>sql=select * from table1 where field1 like 'Test%' and
concat>sql, field2 in (%holder%)
mdl>sql
This will work and you then concat the the next line to the sql since it has a variable holder. and if there's another string like '%' search to the query its likely have to have another line concat as well.
select * from table1 where field1 like 'Test%' and field2 in ('abc','def','ghi').
The above sql string holds what you are actually trying to do:


Just thought i post this since i had to scratch my head for about an hour trying to figure out why it would not run in MS when it ran find under sql server

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1417
Joined: Sun Nov 03, 2002 3:19 am

Post by Dorian (MJT support) » Wed Aug 28, 2013 12:25 am

Thank you, hoang, it's always good to see a question and a solution all in one. :)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts