【问题标题】:Insert variables into temp table using union all使用 union all 将变量插入临时表
【发布时间】:2013-06-25 15:57:34
【问题描述】:

为什么在“dbo”附近出现错误的语法。错误?

SELECT inv_num
INTO #InvoiceList
FROM (
SELECT inv_num = 
    dbo.ExpandKy(10, @Inv1) UNION ALL
    dbo.ExpandKy(10, @Inv2) UNION ALL
    dbo.ExpandKy(10, @Inv3) UNION ALL
    dbo.ExpandKy(10, @Inv4) UNION ALL
    dbo.ExpandKy(10, @Inv5) UNION ALL
    dbo.ExpandKy(10, @Inv6) UNION ALL
    dbo.ExpandKy(10, @Inv7) UNION ALL
    dbo.ExpandKy(10, @Inv8) UNION ALL
    dbo.ExpandKy(10, @Inv9) UNION ALL
    dbo.ExpandKy(10, @Inv10) UNION ALL
    dbo.ExpandKy(10, @Inv11) UNION ALL
    dbo.ExpandKy(10, @Inv12) UNION ALL
    dbo.ExpandKy(10, @Inv13) UNION ALL
    dbo.ExpandKy(10, @Inv14) UNION ALL
    dbo.ExpandKy(10, @Inv15) UNION ALL
    dbo.ExpandKy(10, @Inv16) UNION ALL
    dbo.ExpandKy(10, @Inv17) UNION ALL
    dbo.ExpandKy(10, @Inv18) UNION ALL
    dbo.ExpandKy(10, @Inv19) UNION ALL
    dbo.ExpandKy(10, @Inv20)
) d
WHERE inv_num IS NOT NULL

【问题讨论】:

    标签: sql temp-tables union-all


    【解决方案1】:

    您的联合查询无效。应该是这样的

    select dbo.Exandkey(10, @Inv1) invnum
    union all
    select dbo.Exandkey(10, @Inv2) invnum
    etc
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-13
      • 1970-01-01
      • 2012-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-23
      相关资源
      最近更新 更多