SQL SERVER 2012 Chapter III using INSERT statements to add data

Source: Internet
Author: User

INSERT [TOP (<expression>) [PERCENT] [into] <tabular object>
[(column list)]
[OUTPUT <output Clause>]
{VALUES (<data values>) [, (<data values>)] [,... N]
| <table source>
| EXEC <procedure>
| DEFAULT VALUES

This structure looks like a crash, more basic as follows:

INSERT [into] <table>
[(column list)]
VALUES (<data values>) [, (<data values >)] [,...-N]

MultiRow Insert, as long as the price in the following comma "," You can write a column of values
INSERT into Table
(ID,NAME,PWD)
VALUES
(1, Zhang San, 123),
(2, John Doe, 124)
Inserting multiple data at once can reduce the number of round trips to the server and improve performance.

INSERT into ... SELECT statement

Use AdventureWorks2012;

DECLARE @MyTable Table
(
SalesOrderID int,
CustomerID Char (5)
);

INSERT into @MyTable
SELECT SalesOrderID, CustomerID
From AdventureWorks2012.Sales.SalesOrderHeader
WHERE SalesOrderID between 44000 and 44010;

SELECT *
From @MyTable;

Methods of using temporary tables. Temporary table variables exist only in the batch process.

SQL SERVER 2012 Chapter III using INSERT statements to add data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.