• 表变量、临时表(with as ,create table)


    1.declare @t table(CountryRegionCode nvarchar(3))
    insert into @t(CountryRegionCode)  (select CountryRegionCode from person.CountryRegion where Name like 'C%')

    2.CREATE TABLE #tmp(
    FuncID UNIQUEIDENTIFIER
    )
    INSERT INTO #tmp EXEC usp_Menu_GetMenuByUserID @UserID
    DROP TABLE #tmp

    3.

    WITH p as
    (
    SELECT ProjectID FROM[dbo].[ProjectDepMapping] WHERE OUID = @OUID
    ),
    s as
    (
    SELECT * FROM [dbo].[system20180118] where ID in(select * from p)
    ),
    x as
    (
    SELECT * FROM [dbo].[xmjjrwttj] where festival = @festival and year = @year
    )
    SELECT s.*,
    x.id xmjjrwttjID, x.year, x.userId, x.tbtime, x.sysid,
    x.festival, x.userName, x.paltform,
    ISNULL(x.zbrs,'0') zbrs, ISNULL(x.xczsrc,'0') xczsrc, ISNULL(x.xtkyl,'0') xtkyl, ISNULL(x.wttbs,'0') wttbs,
    ISNULL(x.wtclwcs,'0') wtclwcs, ISNULL(x.wwcwts,'0') wwcwts, ISNULL(x.Emergency,'0') Emergency,
    ISNULL(x.wlkyl,'0') wlkyl, ISNULL(x.llltx,'0') llltx, ISNULL(x.dbl,'0') dbl, ISNULL(x.state,'0') state
    FROM s
    LEFT JOIN x
    ON s.ID = x.sysid

  • 相关阅读:
    同余 扩展欧几里得
    185. [USACO Oct08] 挖水井
    Dijkstra算法
    Floyed算法
    codves——1079 回家
    codves——1021 玛丽卡
    codves——5960 信使
    计算几何基础
    【正睿oi省选十连测】第一场
    [APIO2012]守卫
  • 原文地址:https://www.cnblogs.com/liuqiyun/p/8515807.html
Copyright © 2020-2023  润新知