SQLDML

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Use AdventureWorks2016;

--1
UPDATE Person.Address SET AddressLine2= 'N/A' where AddressLine2 is NULL;
SELECT * from Person.Address;

--2
UPDATE SalesOrderDetail SET UnitPrice= A.ListPrice From Sales.SalesOrderDetail as
SalesOrderDetail INNER JOIN
Production.Product As A on SalesOrderDetail.ProductID=A.ProductID;

--3
DELETE From Person.Person WHERE LastName LIKE 'S%' SELECT * From Person.Person;

--4
DELETE C from Sales.Customer As C INNER JOIN Sales.Customer ON C.CustomerID
=C.CustomerID;
DELETE From Sales.Customer WHERE CustomerID IN (SELECT C.CustomerID From
Sales.Customer
As C LEFT OUTER JOIN Sales.SalesOrderHeader As SOH ON C.CustomerID=SOH.CustomerID
GROUP BY C.CustomerID HAVING SUM (ISNULL(TotalDue,0)) <1000);

--5
SELECT * From Production.Product INSERT INTO
Production.Product(ProductID,Name,Color,StandardCost,ListPrice,Size,Weight)
VALUES ('1001','Rushabh','Orange','500','300','50','25')
SELECT ProductID, Name ,Color, StandardCost,ListPrice,Size,Weight From
Production.Product;

--6
INSERT INTO Production.Product(ProductID, Name, Color, StandardCost, ListPrice,
Size, Weight)
VALUES (711,'Sport-100 Helmet, Blue','Blue', 13.0863,34.99,NULL,NULL),
(712,'AWC Logo Cap','Multi',6.9223,8.99,NULL,NULL),
(713,'Long-Sleeve Logo Jersey,S','Multi',38.4923,49.99,'S',NULL),
(714,'Long-Sleeve Logo Jersey,M','Multi',38.4923,49.99,'M',NULL),
(715,'Long-Sleeve Logo Jersey,L','Multi',38.4923,49.99,'L',NULL);

You might also like