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 7683017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:42:03+00:00 2026-05-31T18:42:03+00:00

I have a Keywords table with the fields KeywordsEn and KeywordsFr. I have another

  • 0

I have a Keywords table with the fields KeywordsEn and KeywordsFr.
I have another MediaObjectsMetadata with the field Values.

I need to check that the Value field contains at least one of the words from the Keywords table (either in KeywordsEn or KeywordsFr field).

I thought I would use the Contains function like this, where @priorityKeywords contains all the KeywordsEn and KeywordsFr concatenated with OR, but then I have over 16000 characters in my string, and the Contains function can only allow 4000.

Part of my SP

SELECT FKMediaObjectId
FROM dbo.gs_MediaObjectMetadata
WHERE UPPER([Description]) = 'KEYWORDS'
AND FKMediaObjectId >= 
  (SELECT TOP 1 MediaObjectId 
  FROM dbo.gs_MediaObject 
  WHERE DateAdded > @lastcheck 
  ORDER BY MediaObjectId) 
  AND Contains([Value] , @priorityKeywords);

C# function which generates @priorityKeywords

public static string GetPriorityKeywordsList()
{
  string keywordString = String.Empty;

  using (IDataReader dr = GetCommandPriorityKeywordsList().ExecuteReader(CommandBehavior.CloseConnection))
  {
    while (dr.Read())
    {
      if (keywordString.Length > 0)
      {
         keywordString += " OR ";
      }
      // max 4000 chars allowed in COntains sql function of sp
      keywordString += "'" + dr["KeywordEn"].ToString() + "' OR '" + dr["KeywordFr"].ToString() + "'";
     }
    }
        return keywordString;
}

What solution would you recommend for my stored procedure?

Edit (Solution):

Here is the solution proposed by Andomar, adapted to my situation:

select  *
from    gs_MediaObjectMetadata yt
where   
UPPER([Description]) = 'KEYWORDS'
AND  not exists
        (
        select  *
        from    dbo.fnSplit(Replace(yt.Value, '''', ''''''), ',') split
        where   split.item in (select KeywordEn from gs_Keywords) or split.item in (select KeywordFr from gs_Keywords)
        )
  • 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-05-31T18:42:04+00:00Added an answer on May 31, 2026 at 6:42 pm

    If you’re using SQL Server 2008, you can use a table-valued parameter to pass the list of keywords to the stored procedure. You can use the variable like you would use a table, in a join or an in clause. For example:

    use testdatabase
    go
    if exists (select * from sys.procedures where name = 'TestProc')
        drop procedure TestProc
    if exists (select * from sys.types where name = 'TestProcList')
        drop type TestProcList
    go
    create type TestProcList as table (keyword varchar(50))
    go
    create procedure dbo.TestProc(
        @list TestProcList readonly)
    as
    select  *
    from    YourTable
    where   value in (select keyword from @list)
    go
    

    EDIT: if you have more than one keyword in the value field, you could use a split function. For example:

    select  *
    from    YourTable yt
    where   not exists
            (
            select  *
            from    dbo.fnSplit(yt.value, " ") split
            where   split.item not in (select keyword from @list)
            )
    

    This demands that all keywords in the value column (separated by a space) are present in the @list parameter.

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

Sidebar

Related Questions

i have a keywords table,and i want to check a String contains keyword or
I have this table that has a lot of book related fields including keywords.
I have a database table that contain two fields Categories and Tags i need
I have two tables that are related via a mapping table: keywords titles I
I have two tables that I need to compare and update values in one
So I have a table with a field that I wish to work with
I have title (varchar), description (text), keywords (varchar) fields in my mysql table. I
I have a course table which I need to search based on keywords typed
I have a table in MySql with several different fields, one of them contains
I have this XML in a column in my table: <keywords> <keyword name=First Name

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.