大家来看看我这个存储过程。。。
ALTER PROCEDURE [dbo].[usp_WhiteCardReplacements_GetEmailInfoToTable]
@CardNo nvarchar(50),
@LostDate nvarchar(20),
@City nvarchar(20),
@Provicne nvarchar(10),
@MailName nvarchar(30),
@MobilePhone nvarchar(30),
@Address nvarchar(100),
@ZipCode nvarchar(10),
@Email nvarchar(50),
@CardStatus int
AS
BEGIN
declare @CaseNo nvarchar(20)
declare @Date nvarchar(10)
declare @TableCount int
declare @ID int
declare @IsHandle bit=0
set @CaseNo='M'
select @Date=substring(convert(varchar(10),getdate(),112),3,10)
select @TableCount=count(*) from dbo.WhiteCardReplacementData
where datediff(dd,CreateDate,getdate())=0
set @CaseNo=@CaseNo+@Date+'#'+cast(@TableCount+1 as nvarchar)
print @CaseNo
if @CardStatus=5
begin
set @IsHandle=1
end
else
begin
set @IsHandle=0
end
END