zoukankan      html  css  js  c++  java
  • Get WMS Static GoodLocation By Dynamic SQL

    Dynamic SQL Store Procedure:
    Note:
    use variable,you need convert varchar and as a variable,not directly use variable,like this: '+convert(varchar(10),@init_column)+'    '+@the_column_name+'
    create procedure sp_getgoodlocationviaplatoon
        @the_platoon int
    as
    begin
    declare @the_column_name varchar(
    32) declare @sql varchar(8000) declare @init_column int declare @the_column int begin select @the_column=max(F_column) from Sys_GoodLocation select @sql = 'select F_Floor, ' set @init_column=1 set @the_column_name=concat('[',@init_column,']') while @init_column<@the_column begin set @sql= @sql + 'sum(case F_Column when '+convert(varchar(10),@init_column)+' then F_GoodLocationNum else 0 end) as '+@the_column_name+',' --print @sql set @init_column=@init_column+1 set @the_column_name=concat('[',@init_column,']') end if @init_column=@the_column begin set @sql= @sql + 'sum(case F_Column when '+convert(varchar(10),@init_column)+' then F_GoodLocationNum else 0 end) as '+@the_column_name+'' end select @sql= @sql + ' from Sys_GoodLocation where F_Platoon='+convert(varchar(10),@the_platoon)+' group by F_Floor order by F_Floor' exec(@sql) end end
    go

    Call:

    exec sp_getgoodlocationviaplatoon 1
    exec sp_getgoodlocationviaplatoon 2
    exec sp_getgoodlocationviaplatoon 3

    Result:

  • 相关阅读:
    【做题】agc003E
    步态识别问题简介
    win10 +Kinect V1 1414环境配置
    生物特征识别数据泄露事件
    人脸识别应用领域
    爱自然
    wxid 转微信号
    Blahut-Arimoto algorithm Matlab源码
    Theorem、Proposition、Lemma和Corollary等的解释与区别
    PokerNet-poker recognition: 扑克识别 (6)
  • 原文地址:https://www.cnblogs.com/AriLee/p/10752542.html
Copyright © 2011-2022 走看看