Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2014
    Posts
    2

    Unanswered: Insert multiple values into single column

    Can you please suggest me how to perform this insert.

    The string ('123,456,789') is coming from in put variable p_id from a stored procedure.
    and it can be anything second time like ('001,110,100')


    Values ('123,456,789')

    This has to end up into the table like below

    123
    456
    789


    The only way i see achieving this is with below insert , but big challenge is before every "semi column" need to add ') so that values get separated.

    INSERT INTO dev(id) VALUES('123'),('456'),('789')

    please help me in resolving this issue.

    Thanks,
    Dev

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I would parse the string and loop to do multiple insert operations. Dynamic SQL would be my last choice for many reasons, including security, code reliability, etc.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •