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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:38:50+00:00 2026-06-10T22:38:50+00:00

If have a string passed from a .Net application that looks like the below

  • 0

If have a string passed from a .Net application that looks like the below

2023|F66451,1684|648521,1684|600271,2137|019592

I have started to parse out the string using the method below but I need to Pivot the data returned from the Split ( surrounded by *’s) function in order to insert into the #tmpExceptions table

DECLARE @ExceptionsList as nvarchar(MAX)

SET @ExceptionsList = '2023|F66451,1684|648521,1684|600271,2137|019592'

SET NOCOUNT ON;

DECLARE @CurrentLineItem as nvarchar(255)

CREATE TABLE #ParsePassOne
(
    LineItem nvarchar(255)
)

CREATE TABLE #tmpExceptions
(
    AccountNumber int,
    ClaimNumber nvarchar(50)
)

INSERT INTO #ParsePassOne
    SELECT value FROM Split( ',' ,@ExceptionsList)

WHILE EXISTS(SELECT LineItem FROM #ParsePassOne)
    BEGIN
        SELECT TOP 1 @CurrentLineItem = LineItem FROM #ParsePassOne

        *******
            SELECT value FROM Split( '|' ,@CurrentLineItem) 
            *******

        DELETE FROM #ParsePassOne WHERE LineItem = @CurrentLineItem
    END

SELECT * FROM #tmpExceptions

DROP TABLE #ParsePassOne
DROP TABLE #tmpExceptions

So far the data returned looks as below. I just need to pivot the data to columns so I can insert it. How do I go about this?

enter image description here

Split Function

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--Creates an 'InLine' Table Valued Function (TVF)
ALTER FUNCTION [dbo].[Split] 
   (  @Delimiter varchar(5), 
      @List      varchar(8000)
   ) 
   RETURNS @TableOfValues table 
      (  RowID   smallint IDENTITY(1,1), 
         [Value] varchar(50) 
      ) 
AS 
   BEGIN

      DECLARE @LenString int 

      WHILE len( @List ) > 0 
         BEGIN 

            SELECT @LenString = 
               (CASE charindex( @Delimiter, @List ) 
                   WHEN 0 THEN len( @List ) 
                   ELSE ( charindex( @Delimiter, @List ) -1 )
                END
               ) 

            INSERT INTO @TableOfValues 
               SELECT substring( @List, 1, @LenString )

            SELECT @List = 
               (CASE ( len( @List ) - @LenString ) 
                   WHEN 0 THEN '' 
                   ELSE right( @List, len( @List ) - @LenString - 1 ) 
                END
               ) 
         END

      RETURN 

   END 
  • 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-10T22:38:51+00:00Added an answer on June 10, 2026 at 10:38 pm

    You can replace your WHILE EXISTS(SELECT LineItem FROM #ParsePassOne) loop with

    select *
    from
    (
    select * from #parsepassone
        cross apply dbo.Split( '|' ,lineitem)  
    ) src
    pivot
    (max(value) for rowid in ([1],[2]))p
    

    Or replace the whole thing with

    insert #tmpExceptions (AccountNumber, ClaimNumber)
    select [1],[2]
    from
    (
    select e.rowid e, p.* from dbo.Split( ',' ,@ExceptionsList) e
        cross apply dbo.Split( '|' ,e.value) p ) s
    pivot
    (max(value) for rowid in ([1],[2]))p
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been passed a date string that looks like this: Thu%20Mar%2011%202010%2015%3A09%3A11%20GMT%2B0000%20(BST) I want
I'm attempting to build a method call from strings that have been passed into
I have a string that I want passed via the linebreaks filter. {% trans
I have a JS function which is passed a string that a RegEx is
I found one sample application from the Blackberry knowledgebase. From that application I have
This is C#/.NET 2.0. So I have string that contains the future contents of
I have a string that I am trying to pass from my C# app
I have a string in KOI8-R encoding, it's passed as argv, so initially it's
Background: I have string of html with about 10 image tags that passes through
I have an example json as below: { Passwd:String content, Userme:String content } how

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.