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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:32:12+00:00 2026-05-23T10:32:12+00:00

I am trying to determine the word frequency in a column that is a

  • 0

I am trying to determine the word frequency in a column that is a VARCHAR(3000). I am not sure if this is the best data type but the table creation was not in hand. In any case, I have been using the following function (taken from here) to split strings up until this point:

CREATE FUNCTION dbo.Split
(
    @RowData nvarchar(2000),
    @SplitOn nvarchar(5)
)  
RETURNS @RtnValue table 
(
    Id int identity(1,1),
    Data nvarchar(100)
) 
AS  
BEGIN 
    Declare @Cnt int
    Set @Cnt = 1

    While (Charindex(@SplitOn,@RowData)>0)
    Begin
        Insert Into @RtnValue (data)
        Select 
            Data = ltrim(rtrim(Substring(@RowData,1,Charindex(@SplitOn,@RowData)-1)))

        Set @RowData = Substring(@RowData,Charindex(@SplitOn,@RowData)+1,len(@RowData))
        Set @Cnt = @Cnt + 1
    End

    Insert Into @RtnValue (data)
    Select Data = ltrim(rtrim(@RowData))

    Return
END

Usage was as follows:

SELECT s FROM dbo.Split(' ', @description)

It has been working very nicely but now I am getting an error:

The statement terminated. The maximum
recursion 100 has been exhausted
before statement completion.

Does anyone have suggestions on what is a good way of achieving this?

  • 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-23T10:32:13+00:00Added an answer on May 23, 2026 at 10:32 am

    Never mind. Just in case someone else faces the same problem, the following from here works perfect on large strings:

    CREATE FUNCTION dbo.SplitLarge(@String varchar(8000), @Delimiter char(1))     
    returns @temptable TABLE (items varchar(8000))     
    as     
    begin     
        declare @idx int     
        declare @slice varchar(8000)     
    
        select @idx = 1     
            if len(@String)<1 or @String is null  return     
    
        while @idx!= 0     
        begin     
            set @idx = charindex(@Delimiter,@String)     
            if @idx!=0     
                set @slice = left(@String,@idx - 1)     
            else     
                set @slice = @String     
    
            if(len(@slice)>0)
                insert into @temptable(Items) values(@slice)     
    
            set @String = right(@String,len(@String) - @idx)     
            if len(@String) = 0 break     
        end 
    return     
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not sure how to word this. I am trying to use a variable to
I am trying to determine which implementation of the data structure would be best
I'm not sure if this is possible, but is there a way (pre-written library
I am trying to determine the best way to create a treeview list in
I am trying to determine the type of a property which an attribute relates
I'm trying to determine if there is a way to accomplish this elegantly. I
I'm trying to determine whether it's possible to create css for an element that
I'm trying to determine the relationship between default values and the has_foo() methods that
I'm trying to determine the location that is a certain distance and heading from
I am trying to determine the best way to enforce password expiration rules in

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.