SQL Server/T-SQL/Transact SQL/Delete Data — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 10:20, 26 мая 2010
Delete in a stored procedure
5> CREATE TABLE OrderDetails(
6> orderID int NOT NULL,
7> PartID int NOT NULL,
8> Quantity int NOT NULL);
9> GO
1>
2>
3>
4> INSERT INTO OrderDetails VALUES(10001, 11, 12)
5> INSERT INTO OrderDetails VALUES(10001, 42, 10)
6> INSERT INTO OrderDetails VALUES(10001, 72, 5)
7> INSERT INTO OrderDetails VALUES(10002, 14, 9)
8> INSERT INTO OrderDetails VALUES(10002, 51, 40)
9> INSERT INTO OrderDetails VALUES(10003, 41, 10)
10> INSERT INTO OrderDetails VALUES(10003, 61, 35)
11> INSERT INTO OrderDetails VALUES(10003, 65, 15)
12>
13> GO
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
(1 rows affected)
1>
2> CREATE PROC dbo.usp_OrderDetailsDelete
3> @orderid int,
4> @partid int
5> AS
6> DELETE FROM OrderDetails
7> WHERE
8> orderid = @orderid
9> AND
10> partid = @partid
11> GO
1>
2>
3> drop table OrderDetails;
4> GO