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获取所有被引用函数,并将库同代码一起放 ...
随机推荐
- js 禁止f12、Ctrl +S 、右键
<script language=javascript> window.onload=function(){ document.onkeydown=function(){ ]; ){ re ...
- Cookie 判断页面是否为第一次打开 包括刷新
$.cookie = function(e, t, n) { if(arguments.length > 1 && (!/Object/.test(Object.prototyp ...
- Python中的 @staticmethod@classmethod方法
python类中有三种方法,常见的是实例方法,另外两种是staticmethod装饰的静态方法,和classmethod装饰的类方法. 1.对比 流畅的python里,用一个例子进行了对比: (1)两 ...
- oAuth2授权协议 & 微信授权登陆和绑定 & 多环境共用一个微信开发平台回调设置
OAuth2(open Auth)开放授权协议 授权码模式流程: 1.浏览器(客户端)点击一个比如使用微信登陆按钮 2.会跳到认证服务器页面,让用户选择是否授权 3.如果用户点击授权,那么会跳转到开始 ...
- java 利用jsoup 爬取知乎首页问题
今天学了下java的爬虫,首先要下载jsoup的包,然后导入,导入过程:首先右击工程:Build Path ->configure Build Path,再点击Add External JARS ...
- OrCAD Capture CIS 16.6 将版本16.6的设计文件另存为版本16.2的设计文件
操作系统:Windows 10 x64 工具1:OrCAD Capture CIS 16.6-S062 (v16-6-112FF) 启动OrCAD Capture CIS,打开.dsn设计文件,右击该 ...
- 业务线--node中间层做一个透传的项目
1,node中间层总结 1,ejs引入vue的js,路由层(直接透传,自定义行的),比较浅层的一层 中间件的引入 ? ) { // 与rd约定,接口成功返回code===0,其余为失败 console ...
- .Net Core 部署到IIS
微软官方教程: https://docs.microsoft.com/en-us/aspnet/core/publishing/iis?tabs=aspnetcore2x 在vs中创建.net cor ...
- 我的 FPGA 学习历程(05)—— 使用 Modelsim 仿真工具
在第 3 篇中讲到了如何使用图形进行仿真激励输入,图形输入法尽管简单易学,但如若要求复杂的仿真输入激励.较长的仿真时间或是要求打印输出信息乃至输出文件日志则显得不够用了. 本篇以上一篇的 3-8 译码 ...
- jade模版js中接收express的res.render
router: router.get('/', function(req, res, next) { res.render('index', { title:{name:'aaa',age:23} } ...