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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:46:40+00:00 2026-05-15T09:46:40+00:00

i want to insert values into a table, with an INSERT INTO statement but

  • 0

i want to insert values into a table, with an INSERT INTO statement but i would like to use a different delimiter (not a comma) how do i do this?

i dont want to use a comma for the following reason:

the data is in this format:

|something|somethingelse|something3 ,moretextinsamefield|

field1 = "something"
field2 = "somethingelse"
field3 = "something3 ,something4"
  • 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-15T09:46:41+00:00Added an answer on May 15, 2026 at 9:46 am

    Writing SQL to do this will get very complicated very quickly, with a bunch of nested Mid() and InStr() functions.

    Instead, I’d do it with a function that uses Split().

      Public Function SplitField(varInput As Variant, strDelimiter As String, lngItemRequested As Long) As Variant
        Dim varTemp As Variant
        Dim arrInput() As String
    
        varTemp = varInput
        If Left(varTemp, 1) = strDelimiter Then
           varTemp = Mid(varTemp, 2)
        End If
        If right(varTemp, 1) = strDelimiter Then
           varTemp = Left(varTemp, Len(varTemp) - 1)
        End If
        arrInput = Split(varTemp, strDelimiter)
        If lngItemRequested - 1 <= UBound(arrInput()) Then
           SplitField = arrInput(lngItemRequested - 1)
           If SplitField = vbNullString Then
              SplitField = Null
           End If
        Else
           SplitField = Null
        End If
      End Function
    

    Then in SQL, you’d call it thus:

      INSERT INTO TargetTable( Field1, Field2, Field3, Field4 )
      SELECT SourceTable.SourceField, SplitField([SourceField],"|",1),
        SplitField([SourceField],"|",2), 
        SplitField([SourceField],"|",3), 
        SplitField([SourceField],"|",4)
      FROM SourceTable
    

    Note that the function I wrote can be used even when there is a variable number of subparts in the source field. That is, if some have 4 parts and some 2, it doesn’t matter, as the function returns Null for the parts that aren’t there.

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

Sidebar

Related Questions

i want to insert the values of two arrays into a table in a
I execute an INSERT INTO statement cursor.execute(INSERT INTO mytable(height) VALUES(%s),(height)) and I want to
I would like to combine insert/update with a case statement, meaning that I want
I want to insert values that are stored in a dictionary into a table.
Using VB.Net I want to get a all datagrid cell values, then insert into
I have the following table: I want to insert values from the MySQL workbench.
I have the following code below which works, but I want to insert values
Using C# in Visual Studio, I'm inserting a row into a table like this:
I read this question , which highlights a solution to conditionally insert values into
I am inserting a row into a table and would like to get the

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.