SQL Wildcard Issue

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
AndrewT
Junior Coder
Posts: 38
Joined: Thu Sep 17, 2015 6:06 pm

SQL Wildcard Issue

Post by AndrewT » Fri Nov 06, 2015 9:45 pm

I am having a problem with the following lines:

Code: Select all

GetDialogProperty>PartLookUpDialog,PartCode,Text,varCode
GetDialogProperty>PartLookUpDialog,PartDesc,Text,varDescrip
Let>PartStr=Select Products.Code, Products."Desc" From "Products" where (Products.Code Like '%varCode%%') and (Products."Desc" Like '%varDescrip%%')
I want the extra % after the variable value for a "begins with" search, but the result I see in the Watch List window is:

Code: Select all

0: PARTSTR=Select Products.Code, Products."Desc" From "Products" where (Products.Code Like '%') and (Products."Desc" Like '%varDescrip%%')
0: VARDESCRIP=USE
0: VARCODE=
I think the extra % wildcards are confusing MS as to what is a variable and what isn't.

Anyone know a way around this?

Thanks
Andrew

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: SQL Wildcard Issue

Post by JRL » Sat Nov 07, 2015 2:09 am

Try using a variable whose value is "%"

Code: Select all

Let>percent=%
GetDialogProperty>PartLookUpDialog,PartCode,Text,varCode
GetDialogProperty>PartLookUpDialog,PartDesc,Text,varDescrip
Let>PartStr=Select Products.Code, Products."Desc" From "Products" where (Products.Code Like '%varCode%%percent%') and (Products."Desc" Like '%varDescrip%%percent%')

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Re: SQL Wildcard Issue

Post by armsys » Sat Nov 07, 2015 2:56 am

JRL wrote:Try using a variable whose value is "%"
Hi JRL,
Thank you for your solution.

AndrewT
Junior Coder
Posts: 38
Joined: Thu Sep 17, 2015 6:06 pm

Re: SQL Wildcard Issue

Post by AndrewT » Mon Nov 09, 2015 1:38 pm

That did it.

Thank you JRL!

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