Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8759549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:49:50+00:00 2026-06-13T14:49:50+00:00

I have been staring at this for too long and I can’t seem to

  • 0

I have been staring at this for too long and I can’t seem to see where I went wrong.

I have a stored procedure that has to return a bunch of data where the "ExtractedText" matches the word the person is searching for:

Select @Command = 'select DISTINCT CaseFileEvents.InvestigatorID,convert(nvarchar,EventDate,111) as ''EventDate'',EventTime,EventDesc,TaskID,Privileged,Private,Email,HasAttachments,FName,LName, FName + '' '' + LName as Name ,CaseFileEvents.FileID,CaseFiles.FileName,ItemEntryGradeID, EventDescPlainText
                from CaseFileEvents
                join ......

                WHERE '+ @FilterField +' LIKE ''%' + @FilterQuery + '%'' ORDER BY ' + @SortName + ' ' + @SortOrder + ''; this area seems to bug out

@FilterField is a column in one of the tables, @FilterQuery is the word the user typed in that it is looking for. @SortName, is the name by wich it gets sorted.

Command examples: @FilterField = "ExtractedText", @FilterQuery="something", @SortName="EventID", @SortOrder="desc"

This is the error:

Msg 156, Level 15, State 1, Line 10
Incorrect syntax near the keyword ‘ORDER’.

Full command:

WHERE ExtractedText LIKE '%add%' ORDER BY EventID desc;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:49:52+00:00Added an answer on June 13, 2026 at 2:49 pm

    The reason why it didn’t work is because I was missing
    WHERE EventID = convert(nvarcahr,@EventID)
    and just took out “DISTINCT”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I may have just been staring at this too long, or maybe I just
First, let me say that I have been at this for far too long,
I have been staring at this code and cannot figure out what is wrong
I've been trying to debug this for far too long, and I obviously have
I have been stuck on this problem for too long and would love some
Perhaps I have been looking at this for too long as I cannot find
I have been staring at this code for few hours, tried walkthrough,debugging with autos
Now I do have a hw question for everyone...I've been staring at this for
I have been passed a date string that looks like this: Thu%20Mar%2011%202010%2015%3A09%3A11%20GMT%2B0000%20(BST) I want
I've been thinking about this far too long and haven't gotten any idea, maybe

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.