Insert Multiple Rows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rocketfuel
    New Member
    • Nov 2007
    • 7

    Insert Multiple Rows

    Hi All

    I have the following query in a vb program that inserts multiple rows in a table. The database resides on a server running SQL Server 2005.

    Code:
    Insert into TableX values (val1,val2,val3),(val1,val2,val3),(val1,val2,val3),(etc)
    It processes about 12 rows and then I get the error.
    Run-time error '-2147217900 (80040e14)':
    Incorrect syntax near ',' .

    Any help would be appreciated.
    Thanks
  • Jim Doherty
    Recognized Expert Contributor
    • Aug 2007
    • 897

    #2
    Originally posted by Rocketfuel
    Hi All

    I have the following query in a vb program that inserts multiple rows in a table. The database resides on a server running SQL Server 2005.

    Code:
    Insert into TableX values (val1,val2,val3),(val1,val2,val3),(val1,val2,val3),(etc)
    It processes about 12 rows and then I get the error.
    Run-time error '-2147217900 (80040e14)':
    Incorrect syntax near ',' .

    Any help would be appreciated.
    Thanks
    Can you post the 'fullness' of that insert SQL in its proper form as you have it exactly please?

    Jim :)

    Comment

    • iburyak
      Recognized Expert Top Contributor
      • Nov 2006
      • 1016

      #3
      It is incorrect syntax and I don’t think it even processes one row.
      Correct syntax should be something like this:

      Code:
      1.	Insert into TableX values (val1,val2,val3)
      2.	Insert into TableX values (val1,val2,val3)
      3.	Insert into TableX values (val1,val2,val3)  
      4.	(etc)

      Good Luck

      Comment

      • Jim Doherty
        Recognized Expert Contributor
        • Aug 2007
        • 897

        #4
        Originally posted by iburyak
        It is incorrect syntax and I don’t think it even processes one row.
        Correct syntax should be something like this:

        Code:
        1.	Insert into TableX values (val1,val2,val3)
        2.	Insert into TableX values (val1,val2,val3)
        3.	Insert into TableX values (val1,val2,val3) 
        4.	(etc)

        Good Luck
        Yes thats my thoughts too I thought maybe rocketfuel had pasted wrongly or got the mouse jitters or something

        Jim :)

        Comment

        • Rocketfuel
          New Member
          • Nov 2007
          • 7

          #5
          Originally posted by Jim Doherty
          Yes thats my thoughts too I thought maybe rocketfuel had pasted wrongly or got the mouse jitters or something

          Jim :)
          I apologise, blame it on mouse jitters. I had to changed a program to output to SQL Server instead of DB2(current). Tangled up the SQL. I got it to work just now.
          Thanks Jim
          Thanks iburyak

          Comment

          Working...