Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamic Where Clause In Stored Procedure
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00634614
Message ID:
00647525
Views:
21
The field names are part of a Dictionary (SQL table). So are the table names and their relationships. VFP is used as a presentation layer only, calling stored procs. for the rest.

Optimizing these queries however is another undertaking. I basically have two types of fiels:
a) single value fields (like: A, D, F, etc.) which are indexed and perform well.
b) multi-value Yes/No fields coded as binary numbers: 0010010010. The only way to extract the values is using: SUBSTRING(field, loc, 1) = '1'. Obviously indexing does not help here. These queries take long to execute. I tried converting the binary numbers to decimals and then somehow query numeric ranges, but I saw no improvement. I have fields that are 80 chars long, so they cannot be converted to numeric values either. Any other suggestions?

You can query multi-value character fields using LIKE operator.
-- field '0010010010'
...
   WHERE myfield LIKE '1?1????????'
-- or
   WHERE myfield LIKE '1?1%'
It'll make query simpplier but wouldn't speed it up in most cases.

Sergey,
that's an interesting approach. Are you sure it will not be faster? First, I can index the field (will that help?). Second, the multiple SUBSTRING(a,x,y) selects (up to 10 sometimes) must have some sort of impact, as compared to a single WHERE myfield LIKE '1?1????????'.
Aristotle
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform