zoukankan      html  css  js  c++  java
  • sql 表变量的使用

    最近第一次使用sql表变量,感觉挺好用,案例如下:

      declare @aaa table(Com_SiteGroupID uniqueidentifier)  --定义表变量

      ---往表变量里写数据

    insert into @aaa select Com_SiteGroupID from Com_SiteGroup where Com_StructureID =@whereId
    union all
    select a.Com_SiteBasicID from Com_SiteBasic a inner join Com_SiteGroup b on
    a.Com_SiteGroupID=b.Com_SiteGroupID where b.Com_StructureID=@whereId

    --读取表变量的数据

    insert into #temp select c.ObjectText,count(*) as CountNum from Sip_HiddenDisposalInfo a
    inner join Sc_InspectionContent b
    on a.Sc_InspectionContentID=b.Sc_InspectionContentId inner join Sc_InspectionItem c
    on b.Sc_InspectionItemId=c.Sc_InspectionItemId where c.CheckLevel=2
    and a.SiteID in (select * from @aaa)
    and a.CreateTime>=@firtTime and a.CreateTime<=@lastTime group by c.ObjectText

  • 相关阅读:
    iOS9 HTTP 不能正常使用的解决办法
    IOS UIWebView的一些用法总结
    顺序查找
    循环队列
    队列的链式存储实现
    栈的链式存储实现
    顺序表的实现
    MessageBox函数
    二分法查找
    冒泡排序
  • 原文地址:https://www.cnblogs.com/redfull/p/6884492.html
Copyright © 2011-2022 走看看