Skip to content

Instantly share code, notes, and snippets.

@sholsinger
Created October 18, 2010 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sholsinger/632453 to your computer and use it in GitHub Desktop.
Save sholsinger/632453 to your computer and use it in GitHub Desktop.
Parser tells me: Incorrect syntax near the keyword 'ORDER' -- which one?
DECLARE @str VARCHAR(255);
SELECT @str = LOWER(?);
SELECT * (
SELECT TOP 8 * FROM [oca_search_model]
WHERE [osm_isactive] = 1
AND LOWER([osm_category]) = LOWER(?)
AND (
LOWER([osm_keywords]) LIKE '%'+@str+'%'
OR LOWER([osm_description]) LIKE '%'+@str+'%'
OR LOWER([osm_name]) LIKE @str+'%'
) ORDER BY [osm_weight] DESC
) AS T1
ORDER BY [T1].[osm_category] ASC, [osm_weight] DESC, [osm_name] ASC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment