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

  • Home
  • SEARCH
  • 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 634023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:14:56+00:00 2026-05-13T20:14:56+00:00

I have a query to split the data but it is based on a

  • 0

I have a query to split the data but it is based on a delimiter. My query is:

DECLARE @xml xml,@str varchar(100),@delimiter varchar(10)
SET @str= 'VINAYKUMAR,VINAYKUMAR,VINAYKUMAR,VINAYKUMAR,VINAYKUMAR,VINAYKUMAR,VINAYKUMAR'
SET @delimiter =','
SET @xml = cast(('<X>'+replace(@str,@delimiter ,'</X><X>')+'</X>') as xml)
select @xml
SELECT a.value('.','varchar(10)') as value FROM @xml.nodes('X') as X(a)

I want split the data based on length i.e 10 characters.

Thanks in advance.

  • 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-13T20:14:57+00:00Added an answer on May 13, 2026 at 8:14 pm

    Something like… (Edit: separator safe now)

    DECLARE @str varchar(100)
    DECLARE @splitlen tinyint, @hasSeparator bit;
    
    SELECT @str= 'VINAYKUMAR,VINAYKUMAR,VINAYKUMAR,VINAYKUMAR,VINAYKUMAR,VINAYKUMAR,VINAYKUMAR'
    SELECT @splitlen = 10, @hasSeparator = 1
    
    ;WITH cNumber AS 
    (
        SELECT
            ROW_NUMBER() OVER (ORDER BY C1.column_id) * (@splitlen+@hasSeparator) - @splitlen + (1-@hasSeparator) AS Number
        FROM
            sys.columns C1, sys.columns C2
    )
    SELECT
        SUBSTRING(@str, Number, @splitlen-@hasSeparator)
    FROM
        cNumber
    WHERE
        Number < LEN (@str)
    
    
    
    SELECT @str= 'VINAYKUMARVINAYKUMARVINAYKUMARVINAYKUMARVINAYKUMARVINAYKUMARVINAYKUMAR'
    SELECT @splitlen = 10, @hasSeparator = 0
    ;WITH cNumber AS 
    (
        SELECT
            ROW_NUMBER() OVER (ORDER BY C1.column_id) * (@splitlen+@hasSeparator) - @splitlen + (1-@hasSeparator) AS Number
        FROM
            sys.columns C1, sys.columns C2
    )
    SELECT
        SUBSTRING(@str, Number, @splitlen - @hasSeparator)
    FROM
        cNumber
    WHERE
        Number < LEN (@str)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data split across several mysql tables to prevent data duplication but joining
I have query to show the table like this: but I want to PIVOT
I have a query in Access 2007. It's worked fine for months, but I'm
I have a SQL query I have to perform based on Operator Input. I
I have a query that works perfectly in SQL, but I'm having the damnedest
I have an OperationContract method where I am trying to query and insert data
I have a set of data that shows users, collections of fruit they like,
Hi Guys I have a fully functioning query, but need to do a little
I have query with two MtM relations: $em = $this->getEntityManager(); $qb = $em->createQueryBuilder(); $qb
I have query table copyQuery which has Soil Condition has one of the columns,

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.