if @cy_id <>'ALL'
begin
if @ordertype = 0
select * into #a from ...
else
select * into #a from ...
end
else
begin
if @ordertype = 0
select * into #a from ...
else
select * into #a from ...
end
begin
if @ordertype = 0
select * into #a from ...
else
select * into #a from ...
end
else
begin
if @ordertype = 0
select * into #a from ...
else
select * into #a from ...
end
解决方案 »
- ##########请大家来评论一下这篇文章############
- 请问这是什么原因造成的?
- 最快得到第N条记录的方法(今天刚拿的10分)
- sqlserver2000异常:查询处理器未能用优化程序生成查询计划,因为查询无法同时更新聚集键和 text、ntext 或 image 列。
- 求一条简单的统计排序sql
- 两个表格User和Photos,一对多,怎样用User的RegTime字段值更新到Photos表的UploadTime字段呢?
- 多步 OLE DB 操作产生错误,help!!!
- 想问一个好简单的问题~
- 关于建库!!!(大家帮忙找一找,散分感谢)
- !!!SQL难题。。。如何在运行期间用sql语句在当前表中插入一个字段???高分求救。。。。。
- 触发器发问?
- 如何再新增数据的同时得到自增列的值!
if @ordertype = 0
insert #a from ...
else
insert #a from ...
else
if @ordertype = 0
insert #a from ...
else
insert #a from ...
然后再建该存储过程即可。
if @ordertype = 0
insert #a select * from ...
else
insert #a select * from ... if @ordertype = 0
insert #a select * from ...
else
insert #a select * from ...
if @ordertype = 0
select * into #a from ...
else
select * into #b from ...
else
if @ordertype = 0
select * into #c from ...
else
select * into #d from ...
在查询的时候用:
select * from #a
union all select * from #b
union all select * from #c
union all select * from #d