zoukankan      html  css  js  c++  java
  • 动态SQL

      我觉得非常有必要写篇文章来讲一下动态SQL,待补充...

      

    declare @column varchar(10)
    declare @time varchar(10)
    declare @time2 varchar(10)
    declare @sql varchar(4000)
    set @column=(select 'd'+CONVERT(varchar,DAY(GETDATE()-1))) 
    set @time=(select left(convert(varchar,getdate(),21),7))
    set @time2=(select left(convert(varchar,getdate()-1,21),10))
    set @sql='update a set
    a.'+@column+'=b.InWater
    from WEB_MonthData a , [IPLHSC].[JY].dbo.BAProduceData  b
    where  a.Date_Month='''+@time+''' and b.time_stamp='''+@time2+'''
    and a.ID in(105030) and b.Item=''龙华水司''
    
    update a set
    a.'+@column+'=b.OutWater
    from WEB_MonthData a , [IPLHSC].[JY].dbo.BAProduceData  b
    where  a.Date_Month='''+@time+''' and b.time_stamp='''+@time2+'''
    and a.ID in(105027) and b.Item=''龙华水司'''
    
    print @sql
    exec (@sql)

  • 相关阅读:
    [转]用mamcache 存储session的好处
    [转]怎么写 JQuery插件 (案例原理)
    关于查询优化
    HBase Canary
    HBase Bulk Loading
    有用的技术网站
    HBase 运维分析
    HBase rest
    hbase mlockall
    Jamon
  • 原文地址:https://www.cnblogs.com/yunquan/p/9686630.html
Copyright © 2011-2022 走看看