Forums

This topic is locked

Dynamic Where clause

Posted 31 Aug 2007 08:16:20
1
has voted
31 Aug 2007 08:16:20 Dave Nessim posted:
Hi
If i create an advanced recordset that looks like this
SELECT DISTINCT StateName
FROM dbo.StatesView
WHERE StateName LIKE '[A-F]%'

It returns this

Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
Florida


What i want to be able to do is use a query string variable for the Start and finish variables
so I tried this (so i can specify the start and finish letters of the beginging of the state name.


SELECT DISTINCT StateName
FROM dbo.StatesView
WHERE StateName LIKE '[vfrom-vto]%'

Name:vfrom
Type:Text
Value:Request.QueryString("from"
Default value;%

Name:vto
Type:Text
Value:Request.QueryString("to"
Default value:%

When I test this i get this error
data types varchar and varchar are incompatible with the modulo operator

How do i make this work?
Thanks
Dave




Dave Nessim

Reply to this topic