Saturday 2 November 2024

Table Insert operator in SQL Server execution plan

The table insert operator is seen in the execution plan when we are using insert statement is our query for single insert or a batch process. The Table Insert operator performs the actual row insertion into the table or an index.

Table Insert operator in the following scenarios

Ø  INSERT INTO statements when rows are being added to a table.

Ø  MERGE statements when rows are inserted as part of the merge process.

Ø  SELECT INTO when new rows are inserted into a new table.

Ø  Bulk insert operations

Icon for Table insert Operator

See the example

SELECT INTO when new rows are inserted into a new table.

INSERT into salesorderdetail (salesorderid,

                                  carriertrackingnumber,

                                  orderqty,

                                  productid,

                                  specialofferid,

                                  unitprice,

                                  unitpricediscount,

                                  linetotal

)

select  top 1 salesorderid,

                                 carriertrackingnumber,

                                 orderqty,

                                 productid,

                                 specialofferid,

                                 unitprice,

                                 unitpricediscount,

                                 linetotal

from adventureworks2019.Sales.salesorderdetail

 

See another example to insert one record

INSERT into salesorderdetail (salesorderid,

                                  carriertrackingnumber,

                                  orderqty,

                                  productid,

                                  specialofferid,

                                  unitprice,

                                  unitpricediscount,

                                  linetotal

)values

(43659,'4911-403C-98',1,776,1,2024.994,0,2024.994000)

See the execution plan

No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts