sql会话

alter PROCEDURE [BAD_GET_BASE_INFO]
@unit int,
@billno varchar(30)
AS
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

declare @count int
IF(@unit>0)
SELECT @count=count() FROM bad WHERE unit=@unit
else
SELECT @count=count(
) FROM bad WHERE unit=(SELECT top 1 unit FROM b_tyd WHERE billno=@billno)

IF(@count>0)
begin
declare @s varchar(1000)
set @s='运单号为%d(货号为%s)的运单已经登记过货损信息了!'+char(13)+char(10)+'如果需要修改,请在营运中心-异常登记中处理!'
raiserror(@s,16,1,@unit,@billno)
end
else
begin
IF(@billno='' or (@unit <> 0 AND @billno <> '')) --按运单号
SELECT unit,billno,product,qty,package,billdate, bsite,esite,shipper,consignee, accdeclare,accsafe FROM b_tyd WHERE unit=@unit

 IF(@unit=0) --按货号
    SELECT  unit,billno,product,qty,package,billdate, bsite,esite,shipper,consignee, accdeclare,accsafe  FROM b_tyd  WHERE  billno=@billno

end

你可能感兴趣的:(sql会话)