Code
--0. Clear old table
if object_id('tempdb..#t') is not null
begin
drop table #T
end
--1. Constructs a empty temp table
SELECT dbo.Categories.CategoryName, dbo.Suppliers.CompanyName, dbo.Products.ProductID, dbo.Products.ProductName, dbo.Products.SupplierID,
dbo.Products.CategoryID, dbo.Products.QuantityPerUnit, dbo.Products.UnitPrice, dbo.Products.UnitsInStock, dbo.Products.UnitsOnOrder,
dbo.Products.ReorderLevel, dbo.Products.Discontinued
into #T
FROM dbo.Categories INNER JOIN
dbo.Products ON dbo.Categories.CategoryID = dbo.Products.CategoryID INNER JOIN
dbo.Suppliers ON dbo.Products.SupplierID = dbo.Suppliers.SupplierID
where 1=0
--2. Inserts data generated from SP
insert #t exec dbo.Pr_ProductAll
--3. Shows the result
select * from #t
注意:使用Northwind数据库.
|