我有这个疑问,
Declare @Prcocessrate float
declare @item varchar(20)
declare @process varchar(20)
declare @branch varchar(20)
set @item = 'shirt'
set @process = 'kt'
set @branch = '1'
select @Prcocessrate = ProcessPrice from itemwiseprocessrate where itemname=@Item and Process=@process and branchid=@branch
当我单手运行它时,执行计划只显示3 个步骤,你自己看看..
但我有procedure
sp_newBooking
这个
ALTER PROC sp_newbooking
-- other arguements--
AS
BEGIN
--OTHER FLAGS--
ELSE IF (@Flag = 32)
BEGIN
declare @ItemId varchar(max),@ProcessRate float
--set @BranchId='1'
select @ProcessCode = DefaultProcessCode from mstconfigsettings where branchid=@BranchId
select @ItemId= DefaultItemId from mstconfigsettings where branchid=@BranchId
select @ItemName= ItemName from itemmaster where itemid=@ItemId and branchid=@BranchId
select @ProcessRate = ProcessPrice from itemwiseprocessrate where itemname=@ItemName and ProcessCode=@ProcessCode and branchid=@BranchId
if(@ProcessRate is not null)
select @ItemName as ItemName,@ProcessCode as ProcessCode,@ProcessRate as ProcessRate
else
select @ItemName as ItemName,@ProcessCode as ProcessCode,'0' as ProcessRate
END
-- OTHER FLAGS --
END
现在!,当我运行这个
exec sp_newbooking
@flag = 32,
@Branchid = 1
执行计划显示6个步骤!这是图片..!
见查询 4
为什么从程序执行时执行相同的查询需要 6 个步骤,而单独执行时需要 3 个步骤?这是吗?