IF (EXISTS (SELECT * FROM sys.objects WHERE name = 'usp_yhj_womcaa_Query'))
DROP PROCEDURE usp_yhj_womcaa_Query
GO
CREATE PROCEDURE usp_yhj_womcaa_Query
(
@caa001 NVarChar(100) = NULL,
@caa015 NVarChar(100) = NULL,
@ppbom NVarChar(100) = NULL,
@cj NVarChar(100) = NULL
)
AS
BEGIN
/************************************************************************
程序说明：资料查询

SELECT * FROM yhj_womcaa

usp_yhj_womcaa_Query

************************************************************************/

SET NOCOUNT ON
DECLARE @SQL NVARCHAR(MAX)

SET @SQL='SELECT A.* FROM yhj_womcaa AS A WHERE 1=1 '
IF ISNULL(@caa001,'')<>'' SET @SQL=@SQL+' AND A.caa001 LIKE ''%'+@caa001+'%'''
IF ISNULL(@caa015,'')<>'' SET @SQL=@SQL+' AND A.caa015 LIKE ''%'+@caa015+'%'''
IF ISNULL(@ppbom,'')<>'' SET @SQL=@SQL+' AND A.ppbom LIKE ''%'+@ppbom+'%'''
IF ISNULL(@cj,'')<>'' SET @SQL=@SQL+' AND A.cj LIKE ''%'+@cj+'%'''

--PRINT(@SQL)
EXEC(@SQL)
SET NOCOUNT OFF
END
GO


IF (EXISTS (SELECT * FROM sys.objects WHERE name = 'usp_yhj_womcaa_Delete'))
DROP PROCEDURE usp_yhj_womcaa_Delete
GO
CREATE PROCEDURE usp_yhj_womcaa_Delete
(
@DocNo NVarChar(MAX) --支持批量删除，多个单号用逗号分开
)
AS
BEGIN
/************************************************************************
程序说明：资料查询

SELECT * FROM yhj_womcaa
SELECT * FROM yhj_womcab


usp_yhj_womcaa_Delete '00001' 

************************************************************************/
SET NOCOUNT ON
DELETE yhj_womcaa WHERE ID IN (SELECT COL FROM dbo.ufn_Split(@DocNo,',',1))
DELETE yhj_womcab WHERE PID IN (SELECT COL FROM dbo.ufn_Split(@DocNo,',',1))
SET NOCOUNT OFF
END
GO

IF (EXISTS (SELECT * FROM sys.objects WHERE name = 'usp_yhj_womcaa_GetDataByKey'))
DROP PROCEDURE usp_yhj_womcaa_GetDataByKey
GO
CREATE PROCEDURE usp_yhj_womcaa_GetDataByKey
(
@DocNo NVarChar(100)
)
AS

BEGIN
/************************************************************************
程序说明：资料查询

SELECT * FROM yhj_womcaa
SELECT * FROM yhj_womcab

usp_yhj_womcaa_GetDataByKey '00001' 

************************************************************************/
SET NOCOUNT ON
SELECT A.* FROM yhj_womcaa A WHERE ID=@DocNo
SELECT A.* FROM yhj_womcab A WHERE PID=@DocNo
SET NOCOUNT OFF
END
GO

