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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:32:14+00:00 2026-05-25T03:32:14+00:00

I have a table with a column as nvarchar(max) with text extracted from word

  • 0

I have a table with a column as nvarchar(max) with text extracted from word documents in it. How can I create a select query that I’ll pass another a list of keywords as parameter and return the rows ordered by the number of matches?

Maybe it is possible with full text search?

  • 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-25T03:32:15+00:00Added an answer on May 25, 2026 at 3:32 am

    Yes, possible with full text search, and likely the best answer. For a straight T-SQL solution, you could use a split function and join, e.g. assuming a table of numbers called dbo.Numbers (you may need to decide on a different upper limit):

    SET NOCOUNT ON;
    DECLARE @UpperLimit INT;
    SET @UpperLimit = 200000;
    
    WITH n AS
    (
        SELECT
            rn = ROW_NUMBER() OVER
            (ORDER BY s1.[object_id])
        FROM sys.objects AS s1
        CROSS JOIN sys.objects AS s2
        CROSS JOIN sys.objects AS s3
    )
    SELECT [Number] = rn - 1
    INTO dbo.Numbers
    FROM n
    WHERE rn <= @UpperLimit + 1;
    
    CREATE UNIQUE CLUSTERED INDEX n ON dbo.Numbers([Number]);
    

    And a splitting function that uses that table of numbers:

    CREATE FUNCTION dbo.SplitStrings
    (
        @List NVARCHAR(MAX)
    )
    RETURNS TABLE
    AS
        RETURN
        (
            SELECT DISTINCT
                [Value] = LTRIM(RTRIM(
                    SUBSTRING(@List, [Number],
                    CHARINDEX(N',', @List + N',', [Number]) - [Number])))
            FROM
                dbo.Numbers
            WHERE
                Number <= LEN(@List)
                AND SUBSTRING(N',' + @List, [Number], 1) = N','
        );
    GO
    

    Then you can simply say:

    SELECT key, NvarcharColumn /*, other cols */
    FROM dbo.table AS outerT
    WHERE EXISTS
    (
      SELECT 1 
        FROM dbo.table AS t 
        INNER JOIN dbo.SplitStrings(N'list,of,words') AS s
        ON t.NvarcharColumn LIKE '%' + s.Item + '%'
        WHERE t.key = outerT.key
    );
    

    As a procedure:

    CREATE PROCEDURE dbo.Search
        @List NVARCHAR(MAX)
    AS
    BEGIN
        SET NOCOUNT ON;
    
        SELECT key, NvarcharColumn /*, other cols */
        FROM dbo.table AS outerT
        WHERE EXISTS
        (
          SELECT 1 
            FROM dbo.table AS t 
            INNER JOIN dbo.SplitStrings(@List) AS s
            ON t.NvarcharColumn LIKE '%' + s.Item + '%'
            WHERE t.key = outerT.key
        );
    END
    GO
    

    Then you can just pass in @List (e.g. EXEC dbo.Search @List = N'foo,bar,splunge') from C#.

    This won’t be super fast, but I’m sure it will be quicker than pulling all the data out into C# and double-nested loop it manually.

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

Sidebar

Related Questions

Hey guys, I have a column in an sql server table that is nvarchar(max).
I have a NVARCHAR(max) column in a table and a stored procedure that would
I have a simple table with autoincrementing ID's and one text column. id(int), value(nvarchar)
So I have this working properly: CREATE FUNCTION dbo.GetLiveStream(@UserName NVARCHAR(MAX)) RETURNS TABLE AS RETURN
I have a table in the database where a Description column is of nvarchar(MAX)
I've got a column called description of type NVARCHAR(MAX) - biggest you can have.
I have a column in a table which is of type nvarchar(max) and there
I already have a table with 3 column (Id bigint, Title nvarchar(450), Description nvarchar(MAX))
I have a column in a table so that it is no longer NVARCHAR(256)
I have a table with varbinary(max) column and nvarchar(max) column. One of them is

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.