日期:2014-05-18 浏览次数:20764 次
@zzxbg bit = 1
AS
BEGIN
SET NOCOUNT ON;
WITH tb(Invoice_No, chxi, ForAccountof, NotifyParty, Consignee, gs) AS
(
SELECT a.Invoice_No, a.chxi, c.ForAccountof, c.NotifyParty, c.Consignee, c.gs
from tb1
)
if zzxbg = 1
begin
....
end
END
@zzxbg bit = 1
AS
BEGIN
SET NOCOUNT ON;
WITH tb(Invoice_No, chxi, ForAccountof, NotifyParty, Consignee, gs) AS
(
SELECT a.Invoice_No, a.chxi, c.ForAccountof, c.NotifyParty, c.Consignee, c.gs
from tb1
)
--可以这样
select case @zzxbg when 1 then '' else '' end
END
------解决方案--------------------
不是只能接select
是with 定义了表达式后马上要使用,例如:
declare @t table(id int) ;with m as (select 1 as col) insert into @t select * from m
------解决方案--------------------
定义公用表表达式后,须对其进行引用。 (语法限定)