Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

Insert Records in SQL Statement

In software testing, sometimes QA engineers need to populate data into database tables. Using INSERT statement, we can insert records into a database table.

 

(1) Using Insert statement to add one row into a table

Use AdventureWorks2008
Go
--insert one row
INSERT INTO Production.ProductInventory(ProductID,LocationID,Shelf,Bin,Quantity,rowguid,ModifiedDate)
     VALUES(4,60,'A',10,10,NEWID(),GETDATE())
GO
--Confirm the data insertion
select * from Production.ProductInventory where ProductID=4

(2) Using Insert statement to add multiple rows into a table

Use AdventureWorks2008
Go

--insert multiple rows
INSERT INTO Production.ProductInventory(ProductID,LocationID,Shelf,Bin,Quantity,rowguid,ModifiedDate)
     VALUES(2,60,'A',10,10,NEWID(),GETDATE()),(3,60,'A',10,20,NEWID(),GETDATE())
GO
--Confirm the data insertion
select * from Production.ProductInventory where ProductID in(2,3)