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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:18:06+00:00 2026-06-02T15:18:06+00:00

I am using following method for inserting multiple rows using a single INSERT statement,

  • 0

I am using following method for inserting multiple rows using a single INSERT statement, that is the ANSI style of inserting rows. It is available in SQL Server 2008 and 2012. I am not sure of SQL Server 2005/ 2000.

Create test table:

create table TestInsert (ID INT, Name NVARCHAR(50))

Single INSERT statement to insert 5 rows

INSERT INTO TestInsert 
VALUES (1,'a'),
       (2,'b'),
       (3,'c'),
       (4,'d'),
       (5,'e')

Please let me know if there is any other best way to achieve this

  • 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-02T15:18:07+00:00Added an answer on June 2, 2026 at 3:18 pm

    SQL Server – inserting multiple rows with single (ANSI style) statement

    For SQL Server 2000+

    According to SQL The Complete Reference, Third Edition (August 12, 2009):

    1) The syntax for multirow INSERTs is

    INSERT INTO table-name (columns not mandatory) 
    query
    

    (page 236, Figure 10-3).

    2) The SELECT statement has the FROM clause mandatory (page 87, Figure 6-1).

    So, in this case, to insert multiple rows using just one INSERT statement we need an auxiliary table with just one row:

    CREATE TABLE dual(value INT PRIMARY KEY CHECK(value = 1))
    INSERT dual(value) VALUES(1)
    

    and then

    INSERT INTO table-name (columns) -- the columns are not mandatory
    SELECT values FROM dual
    UNION ALL
    SELECT another-values FROM dual
    UNION ALL
    SELECT another-values FROM dual
    

    Edit 2: For SQL Server 2008+

    Starting with SQL Server 2008 we can use row constructors: (values for row 1), (values for row 2), (values for row 3), etc. (page 218).

    So,

    INSERT INTO TestInsert 
    VALUES (1,'a'), --The string delimiter is ' not ‘...’
           (2,'b'),
           (3,'c'),
           (4,'d'),
           (5,'e')
    

    will work on SQL Server 2008+.

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

Sidebar

Related Questions

i am inserting records to sql server from python using pymssql. The database takes
i'm using the following method for all data inserting and updating processes in my
When I load an .html file into webview using following method and finish its
I'm using the following method to display a frame: public static void createImage(final String
I'm using the following method to send mail from Python using SMTP. Is it
I am using the following method: set_browser_log_level 'off' but my log level continues to
I am using the following method to browse for a file: OpenFileDialog.ShowDialog() PictureNameTextEdit.Text =
I am using the following method for reading Csv file content: /// <summary> ///
I am using the following method to reverse geocode a google maps latlng: [GClientGeocoder.getLocations(address:String,
I am using the following method to basically create a JSON string. var saveData

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.