DECLARE @box CHAR(12)
DECLARE @TZProductName CHAR(12) --
DECLARE @ZXProductName CHAR(12) --
DECLARE @JCProductName CHAR(12) --
SELECT @ProductDescription=ProductDescription FROM dbo.Box
INNER JOIN dbo.Product ON Product.ProductId = Box.ProductId
WHERE BoxCode=@box
IF @ProductDescription NOT LIKE '%内容'
BEGIN
SET @I_ReturnMessage='ServerMessage:请确认输入!!!'
RETURN -1
END
-----创建临时表,获取查询数据后删除临时表,清理空间------
IF OBJECT_ID('tempdb..#TB') IS NOT NULL
DROP TABLE #TB
CREATE TABLE #TB(
StoveBatch CHAR(12),
TZProductName NVARCHAR(50),
ZXProductName NVARCHAR(50),
JCProductName NVARCHAR(50),
ProductSerialNumber2 NVARCHAR(50),
ProductSerialNumber3 NVARCHAR(50)
)
INSERT INTO #TB (
StoveBatch,
TZProductName,
ZXProductName,
JCProductName,
ProductSerialNumber2,
ProductSerialNumber3
)
SELECT
BI.StoveBatch,
@TZProductName,
@ZXProductName,
@JCProductName,
SP.ProductSerialNumber2,
SP.ProductSerialNumber3
FROM dbo.Box B
INNER JOIN dbo.BoxItemlot BI ON BI.BoxId = B.BoxId
INNER JOIN dbo.Product PD ON PD.ProductId = B.ProductId
INNER JOIN dbo.ProductRoot PR ON PR.ProductRootId = PD.ProductRootId
INNER JOIN dbo.SY_Product SP ON SP.ProductId = PD.ProductId
WHERE B.BoxCode=@box
SELECT
StoveBatch as '字段',
@TZProductName as'字段',
@ZXProductName as '字段',
@JCProductName as '字段',
ProductSerialNumber2 as '字段',
ProductSerialNumber3 as '字段'
FROM #TB
DROP TABLE #TB