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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:35:25+00:00 2026-06-04T08:35:25+00:00

I have a problem in writing the query for separating the data from one

  • 0

I have a problem in writing the query for separating the data from one column to multiple column.

Example:

Col1
---------------------------
bank.wrong.transaction
bank.wrong.transaction.captured
business.unit.explored.wrong.way
application.failed

need to put the data into columns like this:

col1      col2           col3
-------------------------------------------------    
wrong     transaction    null
wrong     transaction    captured
unit      explored       wrong
failed    null           null

I don’t know the length of any string at all.

Please help me with this.

Thanks
Saha..

  • 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-04T08:35:26+00:00Added an answer on June 4, 2026 at 8:35 am

    something like the following could be used to get your requested output (cant recall where i robbed the ParseString function from – but i use it all the time, works great)

    CREATE FUNCTION dbo.fnParseString
        (
          @Section SMALLINT ,
          @Delimiter CHAR ,
          @Text VARCHAR(MAX)
        )
    RETURNS VARCHAR(8000)
    AS 
        BEGIN
            DECLARE @NextPos SMALLINT ,
                @LastPos SMALLINT ,
                @Found SMALLINT
    
            --#### Uncomment the following 2 lines to emulate PARSENAME functionality
            --IF @Section > 0 
            --    SELECT  @Text = REVERSE(@Text)
    
            SELECT  @NextPos = CHARINDEX(@Delimiter, @Text, 1) ,
                    @LastPos = 0 ,
                    @Found = 1
    
            WHILE @NextPos > 0
                AND ABS(@Section) <> @Found 
                SELECT  @LastPos = @NextPos ,
                        @NextPos = CHARINDEX(@Delimiter, @Text, @NextPos + 1) ,
                        @Found = @Found + 1
    
            RETURN  CASE
                WHEN @Found <> ABS(@Section) OR @Section = 0 THEN NULL
                --#### Uncomment the following lines to emulate PARSENAME functionality
                --WHEN @Section > 0 THEN REVERSE(SUBSTRING(@Text, @LastPos + 1, CASE WHEN @NextPos = 0 THEN DATALENGTH(@Text) - @LastPos ELSE @NextPos - @LastPos - 1 END))
                WHEN @Section > 0 THEN SUBSTRING(@Text, @LastPos + 1, CASE WHEN @NextPos = 0 THEN DATALENGTH(@Text) - @LastPos ELSE @NextPos - @LastPos - 1 END)
    
                ELSE SUBSTRING(@Text, @LastPos + 1, CASE WHEN @NextPos = 0 THEN DATALENGTH(@Text) - @LastPos ELSE @NextPos - @LastPos - 1 END)
            END
        END
    
    
    
    DECLARE @TestData VARCHAR(255)
    SET @TestData = 'business.unit.explored.wrong.way'
    
    SELECT  dbo.fnParseString(2, '.', @TestData) ,
            dbo.fnParseString(3, '.', @TestData) ,
            dbo.fnParseString(4, '.', @TestData) ,
            dbo.fnParseString(5, '.', @TestData) ,
            dbo.fnParseString(6, '.', @TestData)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a full join sql query and i am retrieving the data from
I have a problem in writing sql query. Here is the illustration about my
I have a problem with mysql query. I am writing SQL query to get
I have no problem in writing data in excel sheet which is stored in
I am having a problem in writing the query for this. I have a
I'm writing a query to get results matching one of multiple phrases, like {
I have a problem with writing a catch clause for an exception that is
I have problem concerning python packages and testing. I'm writing an application using wx
I'm writing an app in Visual Studio C++ and I have problem with assigning
I have come across an annoying problem while writing some PHP4 code. I renamed

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.