SQL SERVER PROCEDURE 创建之牛刀小试(含声明变量)
USE [shzoo0127]
GO
/****** 对象: StoredProcedure [dbo].[PRC_CheckCard_SELECT_t3] 脚本日期: 01/10/2012 23:38:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[PRC_CheckCard_SELECT_t3]
@BARCODE NVARCHAR(50)
AS
SET NOCOUNT ON
DECLARE @MAXDATE NVARCHAR(10);
select @MAXDATE=CONVERT(NVARCHAR(10),MAX(mfcrd_expire),121) from mfcrd_tbl left join TWB_ACCESS_BATCH
on MFCRD_CONTICNO =WBID left join MFCRDTP_TBL on MFCRD_TYPE=MFCRDTP_CARDTYPE
WHERE STATUS='0'
AND wbid = @BARCODE
AND CONVERT(NVARCHAR(10),TCKSTARTDATE,121)<=CONVERT(NVARCHAR(10),GETDATE(),121)
AND CONVERT(NVARCHAR(10),TCKENDDATE,121)>=CONVERT(NVARCHAR(10),GETDATE(),121)
select @MAXDATE
select * from mfcrd_tbl left join TWB_ACCESS_BATCH
on MFCRD_CONTICNO =WBID left join MFCRDTP_TBL on MFCRD_TYPE=MFCRDTP_CARDTYPE
WHERE STATUS='0'
AND wbid = @BARCODE
AND CONVERT(NVARCHAR(10),TCKSTARTDATE,121)<=CONVERT(NVARCHAR(10),GETDATE(),121)
AND CONVERT(NVARCHAR(10),TCKENDDATE,121)>=CONVERT(NVARCHAR(10),GETDATE(),121)
AND CONVERT(NVARCHAR(10),mfcrd_expire,121)=@MAXDATE
select @@ROWCOUNT