|
CREATE TABLE Purchase (
InvoiceID numeric(18, 0) NOT NULL IDENTITY (1, 1),
InvoiceDate datetime NOT NULL,
SupplierName varchar(50) NULL
)
GO
CREATE TABLE PurchaseDetails (
InvoiceID int NOT NULL ,
[Description] varchar (75) NOT NULL ,
Quantity int NOT NULL ,
Rate numeric(18, 2) NOT NULL ,
Amount numeric(18, 2) NOT NULL
)
GO
CREATE PROC InsertPurchaseOrder (@InvoiceDate DATETIME, @SupplierName VARCHAR(50), @PurchaseDetails NTEXT)
AS
BEGIN
DECLARE @InvoiceID INT
DECLARE @idoc INT
INSERT INTO Purchase( InvoiceDate, SupplierName)
VALUES (@InvoiceDate, @SupplierName)
SET @InvoiceID = @@IDENTITY
-- Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @PurchaseDetails
-- Insert the values in the details table
INSERT PurchaseDetails (InvoiceID, [Description], Quantity, Rate, Amount)
SELECT @InvoiceID, [Description], Quantity, Rate, Amount
FROM OPENXML (@idoc, '/PurchaseOrder/Details', 2)
WITH PurchaseDetails
-- Destory the internal representation of the XML document.
EXEC sp_xml_removedocument @idoc
END
GO
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.