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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:52:59+00:00 2026-06-05T12:52:59+00:00

I have a list of objects (created from several text files) in C#.net that

  • 0

I have a list of objects (created from several text files) in C#.net that I need to store in a SQL2005 database file. Unfortunately, Table-Valued Parameters began with SQL2008 so they won’t help. I found from MSDN that one method is to “Bundle multiple data values into delimited strings or XML documents and then pass those text values to a procedure or statement” but I am rather new to stored procedures and need more help than that. I know I could create a stored procedure to create one record then loop through my list and add them, but that’s what I’m trying to avoid. Thanks.

Input file example (Other files contain pricing and availability):
Matnr   ShortDescription    LongDescription ManufPartNo Manufacturer    ManufacturerGlobalDescr GTIN    ProdFamilyID    ProdFamily  ProdClassID ProdClass   ProdSubClassID  ProdSubClass    ArticleCreationDate CNETavailable   CNETid  ListPrice   Weight  Length  Width   Heigth  NoReturn    MayRequireAuthorization EndUserInformation  FreightPolicyException
10000000    A&D ENGINEERING SMALL ADULT CUFF FOR UA-767PBT  UA-279  A&D ENGINEERING A&D ENG 093764011542    GENERAL General TDINTERNL   TD Internal TDINTERNL   TD Internal 2012-05-13 12:18:43 N       18.000  .350                N   N   N   N
10000001    A&D ENGINEERING MEDIUM ADULT CUFF FOR UA-767PBT UA-280  A&D ENGINEERING A&D ENG 093764046070    GENERAL General TDINTERNL   TD Internal TDINTERNL   TD Internal 2012-05-13 12:18:43 N       18.000  .450                N   N   N   N

Some DataBase File fields:

EffectiveDate           varchar(50)
MfgName                 varchar(500)
MfgPartNbr              varchar(500)
Cost                    varchar(200)
QtyOnHand               varchar(200)
  • 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-05T12:53:03+00:00Added an answer on June 5, 2026 at 12:53 pm

    You can split multiple values from a single string quite easily. Say you can bundle the string like this, using a comma to separate “columns”, and a semi-colon to separate “rows”:

    foo, 20120101, 26; bar, 20120612, 32
    

    (This assumes that colons and semi-colons can’t appear naturally in the data; if they can, you’ll need to choose other delimiters.)

    You can build a split routine like this, which includes an output column that allows you to determine the order the value appeared in the original string:

    CREATE FUNCTION dbo.SplitStrings
    (
        @List       NVARCHAR(MAX),
        @Delimiter  NVARCHAR(255)
    )
    RETURNS TABLE
    AS
        RETURN (SELECT Number = ROW_NUMBER() OVER (ORDER BY Number),
            Item FROM (SELECT Number, Item = LTRIM(RTRIM(SUBSTRING(@List, Number, 
            CHARINDEX(@Delimiter, @List + @Delimiter, Number) - Number)))
        FROM (SELECT ROW_NUMBER() OVER (ORDER BY [object_id])
            FROM sys.all_objects) AS n(Number)
        WHERE Number <= CONVERT(INT, LEN(@List))
            AND SUBSTRING(@Delimiter + @List, Number, 1) = @Delimiter
        ) AS y);
    GO
    

    Then you can query it like this (for simplicity and illustration I’m only handling 3 properties but you can extrapolate this for 11 or n):

    DECLARE @x NVARCHAR(MAX); -- a parameter to your stored procedure
    
    SET @x = N'foo, 20120101, 26; bar, 20120612, 32';
    
    ;WITH x AS 
    (
        SELECT ID = s.Number, InnerID = y.Number, y.Item 
        -- parameter and "row" delimiter here:
        FROM dbo.SplitStrings(@x, ';') AS s
        -- output and "column" delimiter here:
        CROSS APPLY dbo.SplitStrings(s.Item, ',') AS y
    )
    SELECT 
        prop1 = x.Item, 
        prop2 = x2.Item, 
        prop3 = x3.Item
    FROM x 
    INNER JOIN x AS x2 
    ON x.InnerID = x2.InnerID - 1
    AND x.ID = x2.ID
    INNER JOIN x AS x3
    ON x2.InnerID = x3.InnerID - 1
    AND x2.ID = x3.ID
    WHERE x.InnerID = 1
    ORDER BY x.ID;
    

    Results:

    prop1   prop2     prop3
    ------  --------  -------
    foo     20120101  26
    bar     20120612  32
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a servlet with several methods that get a list of objects from
I have two list of different objects : List<Report> List<Newsletter> each having a 'created
I have a list of objects that have two int properties. The list is
I have a list of objects and I need to find an object as
I have an array list containing objects from the class EventOnMap . Every object
I have several templated objects that all implement the same interface: I.E. MyObject<datatype1> obj1;
I have several classes (A, B, C, ...) that all use a List<AnotherClass> to
I have inherited a terribly written MS Access database that I need to import
I have an R script that pulls data from a MySQL database, processes it,
I have an application that has several objects (about 50 so far, but growing).

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.