|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Problem parsing dynamic WHERE clause to SPROC
I have a dynamic sql WHERE clause that is built in ASP and sent to a sproc in SQL Server. The string works fine when parsed directly to the sproc in SQL Query Analyser, but when sent to the sproc from an ASP script the sproc fails dues to the quote marks used in the WHERE clause string.
strWhereClause (map_x >= 642343 AND map_y >= 281276) AND (map_x <= 668108 AND map_y <= 307041) AND (pt.property_typeID = ''HDE'' OR pt.property_typeID = ''HSD'' OR pt.property_typeID = ''HTE'') AND (bedrooms BETWEEN 0 AND 8) AND (bathrooms BETWEEN 0 AND 8) AND (sale_statusID = ''FSL'' OR sale_statusID = ''UOF'' OR sale_statusID = ''SLD'') AND (property_termID = ''FRE'' OR property_termID = ''FSH'' OR property_termID = ''LEA'') AND p.listing_typeID = ''S'' Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'HDE'. /tradingplaces/search.asp, line 183 As you can see the where clause contains double single quotes around each variable, is there another type of quote or is there a way around this? For example is there a SQL server equivalent to \' like in javaScript? When run in query analyser with the same WHERE clause it works fine... DECLARE @return int, @row_total int
EXEC @return = LM001_search @where_clause = '(map_x >= 642343 AND map_y >= 281276) AND (map_x <= 668108 AND map_y <= 307041) AND (pt.property_typeID = ''HDE'' OR pt.property_typeID = ''HSD'' OR pt.property_typeID = ''HTE'') AND (bedrooms BETWEEN 0 AND 8) AND (bathrooms BETWEEN 0 AND 8) AND (sale_statusID = ''FSL'' OR sale_statusID = ''UOF'' OR sale_statusID = ''SLD'') AND (property_termID = ''FRE'' OR property_termID = ''FSH'' OR property_termID = ''LEA'') AND p.listing_typeID = ''S''', @page_num = 1, @page_size = 10, @total_rows = @row_total output SELECT @return, @row_total Any ideas??? Thanks, Julian. |
|
#2
|
||||
|
||||
|
Try replacing your double quotes with a single quote.
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Problem parsing dynamic WHERE clause to SPROC |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|