使用字符串拼接函数,创建并解析查询列表条件
2014-07-26 01:38
701 查看
使用字符串拼接函数,创建并解析查询列表条件
Declare @store_list varchar(8000) select @store_list=',1,3,4,6,8,12,' /* select stuff(@store_list , len(@store_list) , 1 ,'') select @store_list=stuff(@store_list , len(@store_list) , 1 ,'')+'''' select @store_list as store_list_2 select @store_list */ select * From Store s where charindex( ',' + convert(varchar, s.store_code_id) + ',', @store_list) > 0
Declare @store_list varchar(8000) --select @store_list='1,3,4,6,8,12' select * From store s where store_code_id in (1,2,6) select @store_list=char(39) select @store_list=@store_list +','+ cast(store_code_id as varchar) From store s where store_code_id in (1,2,6) select @store_list as store_list_1 --select @store_list=@store_list +','+ '''' --select @store_list select sgh.store_grid_id,s.store_code_id,sgh.Description,sgh.username,sgt.grid_type_code,sgt.Description,sg.store_group_description, s.store_code,s.name from store_grid_Header sgh(nolock),Store_Grid_Type sgt (nolock), store_grid_Detail sgd(nolock),store_group sg(nolock),store_group_allocation sga(nolock),store s(nolock) where sgh.grid_type_id=sgt.grid_type_id and sgh.store_grid_id=sgd.store_grid_id and sgd.store_group_id=sg.store_group_id and sg.store_group_id=sga.store_group_id and sga.store_code_id=s.store_code_id and sgt.grid_type_code='pc' and s.store_code like '%R0115%' select @store_list=@store_list +','+ cast(s.store_code_id as varchar) from store_grid_Header sgh(nolock),Store_Grid_Type sgt (nolock), store_grid_Detail sgd(nolock),store_group sg(nolock),store_group_allocation sga(nolock),store s(nolock) where sgh.grid_type_id=sgt.grid_type_id and sgh.store_grid_id=sgd.store_grid_id and sgd.store_group_id=sg.store_group_id and sg.store_group_id=sga.store_group_id and sga.store_code_id=s.store_code_id and sgt.grid_type_code='pc' and s.store_code like '%R0115%' select @store_list as store_list_2 select @store_list=@store_list +','+ char(39) select @store_list as store_list_final select * From Store s where charindex( ',' + convert(varchar, s.store_code_id) + ',', @store_list) > 0
相关文章推荐
- 函数调用缺少参数列表;请使用“&Student::Printf”创建指向成员的指针 问题解析
- 乘法口诀表可以这样打印——使用列表解析创建矩阵
- SQLServer 存储过程中不拼接SQL字符串实现多条件查询
- error C3867: “A::fun1”: 函数调用缺少参数列表;请使用“&A::fun1”创建指向成员的指针
- oracel 数据库使用plsql(创建表,序列,存储过程,触发器) 查询条件为空
- ADF:如何使用VO处理查询条件的值属于某一动态值列表的问题
- “Caculate::writehtml”: 函数调用缺少参数列表;请使用“&Caculate::writehtml”创建指向成员的指针
- SQLServer 存储过程中不拼接SQL字符串实现多条件查询
- 使用反射让linq实现动态查询, 类似拼接sql语句的where 条件
- ORACLE——ROWNUM解析(使用ROWNUM大于条件,无法得到任何查询结果)
- mysql使用参数化查询,like模糊查询,应如何拼接字符串
- 使用'VRM_SET_VALUES'函数创建下拉列表
- SQLServer 存储过程中不拼接SQL字符串实现多条件查询
- SQLServer 存储过程中不拼接SQL字符串实现多条件查询
- SQLServer 存储过程中不拼接SQL字符串实现多条件查询
- SQLServer 存储过程中不拼接SQL字符串实现多条件查询
- SharePoint 2010 使用代码创建视图查询条件
- Sql常见问题总结二(Sql语句怎么样查询IP,游标去重复,各种函数使用,各种取时间格式,字符串精确排序,超时锁问题)
- sql中保留一位小数的百分比字符串拼接,替换函数,换行符使用
- SQL SERVER2000教程-第五章 处理数据 第十七节 使用CASE函数格式进行条件查询