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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:59:50+00:00 2026-05-26T19:59:50+00:00

I have an excel file that has a column that contains a number of

  • 0

I have an excel file that has a column that contains a number of comma-separated IDs for each row, and each row contains another column of text, e.g.

IDs        Text
1          This is a row of text
2,3        Another row of text
4,5,6      More text in this row

I need to insert the text into the a database so that each ID in the first column is split into its own row, and the text is inserted for each ID that it is associated with.

The result in the database would be, e.g.

ID   Text
1    This is a row of text
2    Another row of text
3    Another row of text
4    More text in this row
5    More text in this row
6    More text in this row

Is there any functionality in Excel 2010 or Sql Server 2008 which can do this for me?

Otherwise, is there functionality in Excel which can split the comma-separated values into rows? I know there is a tool which can split them into new columns, but I need rows. If I can get them into rows, I can do a copypasta to get the text associated with the corresponding IDs.

  • 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-26T19:59:50+00:00Added an answer on May 26, 2026 at 7:59 pm

    You could write a simple little macro that will generate the insert statements for you, and then you could just copy and paste those into management studio:

    Dim i as Integer, j as Integer
    Dim ids as Variant
    
    
    For i = 0 To 100
       ids = Split(ActiveSheet.Cells(i, 1).Value)
    
       For j = 0 To UBound(ids)
          ActiveSheet.Cells(i, 3 + j).Value = "INSERT INTO myTable VALUES (" & ids(j) & ", "  ActiveSheet.Cells(i, 2).Value & ")"      
       Next j
    Next i
    

    Obviously, there are more efficient ways to write the loops and split logic, but for a quick little utility to generate the SQL, this should work well.

    UPDATE: Added a “+ j” to the column mapping for the output, otherwise you will stick each string on top of the previous one, oops 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel file that contains a column full of dates in the
I basically have a program that filters records from one excel file to another
I have an excel file and I want to read each column and create
I have a flat file source from Excel that has a structure like this:
I have an Excel file that has columns A and B, both have data
I have an excel file that has ~10 columns and 1-20 rows. I need
I have a excel file, in which one column has the data set such
I have 20000-50000 entries in an excel file. One column contains the name of
I have an excel file that I need to make some changes. I need
I have an Excel file that I need to import into a (new) Oracle

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.