Get WMS Static GoodLocation By Dynamic SQL
create procedure sp_getgoodlocationviaplatoon
@the_platoon int
as
begin
declare @the_column_name varchar()
declare @sql varchar()
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=
set @the_column_name=concat('[',@init_column,']') while @init_column<@the_column
begin
set @sql= @sql + 'sum(case F_Column when '+convert(varchar(),@init_column)+' then F_GoodLocationNum else 0 end) as '+@the_column_name+','
--print @sql
set @init_column=@init_column+
set @the_column_name=concat('[',@init_column,']')
end
if @init_column=@the_column
begin
set @sql= @sql + 'sum(case F_Column when '+convert(varchar(),@init_column)+' then F_GoodLocationNum else 0 end) as '+@the_column_name+''
end select @sql= @sql + ' from Sys_GoodLocation where F_Platoon='+convert(varchar(),@the_platoon)+' group by F_Floor order by F_Floor'
exec(@sql)
end
end
go
Call:
exec sp_getgoodlocationviaplatoon
exec sp_getgoodlocationviaplatoon
exec sp_getgoodlocationviaplatoon
Result:

Get WMS Static GoodLocation By Dynamic SQL的更多相关文章
- MyBatis(3.2.3) - Dynamic SQL
Sometimes, static SQL queries may not be sufficient for application requirements. We may have to bui ...
- Can I use MyBatis to generate Dynamic SQL without executing it?
Although MyBatis was designed to execute the query after it builds it, you can make use of it's conf ...
- [转]Dynamic SQL & Stored Procedure Usage in T-SQL
转自:http://www.sqlusa.com/bestpractices/training/scripts/dynamicsql/ Dynamic SQL & Stored Procedu ...
- Introduction to Dynamic SQL
The idea of using dynamic SQL is to execute SQL that will potentially generate and execute another S ...
- mybatis Dynamic SQL
reference: http://www.mybatis.org/mybatis-3/dynamic-sql.html Dynamic SQL One of the most powerful fe ...
- mybatis-3 Dynamic SQL
Dynamic SQL One of the most powerful features of MyBatis has always been its Dynamic SQL capabilitie ...
- ABAP动态生成经典应用之Dynamic SQL Excute 程序
[转自http://blog.csdn.net/mysingle/article/details/678598]开发说明:在SAP的系统维护过程中,有时我们需要修改一些Table中的数据,可是很多Ta ...
- myisamchk是用来做什么的?MyISAM Static和MyISAM Dynamic有什么区别?
myisamchk是用来做什么的? 它用来压缩MyISAM[歌1] 表,这减少了磁盘或内存使用. MyISAM Static和MyISAM Dynamic有什么区别? 在MyISAM Static上的 ...
- static lib和dynamic lib
lib分为 staticlib 和 dynamic lib: 静态lib将导出声明和实现都放在lib中,编译后所有代码都嵌入到宿主程序, 链接器从静态链接库LIB获取所有被引用函数,并将库同代码一起放 ...
随机推荐
- GIt -- Window下配置 git
全局配置 git config --global user.name "账户名" git config --global use r.email '账户邮箱' 生成ssh,命令 ...
- 【原创】大数据基础之SPARK(9)SPARK中COLLECT和TAKE实现原理
spark中要将计算结果取回driver,有两种方式:collect和take,这两种方式有什么差别?来看代码: org.apache.spark.rdd.RDD /** * Return an ar ...
- springboot ****使用经验*******
目录 1. 返回时间格式化问题 2. springboot 中获取属性 3. SpringBoot中启动是忽略某项检测 4. 启动不开启安全校验 一返回时间格式化问题 在Spring Boot项目中 ...
- unity读取txt,并且生成vector3的数组
读取txt的脚本: public void ReadFileTX(){ var str = File.ReadAllText(Application.streamingAssetsPath + &qu ...
- vue 使用swiper的一些问题(页面渲染问题)
//Swiper上下滚动初始化 swiper_init(){ this.$nextTick(function(){ var mySwiper = new Swiper ('.swiper-contai ...
- 阿里云centos7成功安装和启动nginx,但是外网访问不了的解决方案
问题环境: 阿里云centos7.4.1708 问题描述:成功配置,启动成功,外网访问不了 解决方案: 经过查阅文档,去阿里云后台查看,原来是新购的服务器都加入和实例安全组. (OMG)立即去配置.加 ...
- 配置php5.6.4 + Apache2.4.10
一.下载并安装apache 下载地址:www.apachelounge.com 解压后:执行以下命令: #httpd.exe –k install #httpd.exe -k start 在执行过程中 ...
- Spring 源码分析-1-启动
Spring 源码分析-1-启动 在web项目中使用spring的时候,我们会在web.xml中加入如下配置: <listener> <listener-class>org.s ...
- [转] Vue + Webpack 组件式开发(练习环境)
前言 研究了下别人的 vue 多页面框架, 都是直接复制 package.json 文件,然后在本地 npm install 一下即可, 或者使用官网 vue-cli 工具生成一个项目, 觉得这样虽然 ...
- Android CameraManager 类
先看代码: private SurfaceView mSurfaceView; private SurfaceHolder mSurfaceHolder; private CameraManager ...