declare @type as int
declare @id as int
set @type=3
set @id=1
SELECT
CASE
WHEN @type in(1,4,6) THEN
select
case
when @id in(1) then 'A'
when @id in(2) then 'a'
end
WHEN @type in(2,5) THEN
select
case
when @id in(1) then 'B'
when @id in(2) then 'b'
end
WHEN @type in(3) THEN 'C'
END
declare @id as int
set @type=3
set @id=1
SELECT
CASE
WHEN @type in(1,4,6) THEN
select
case
when @id in(1) then 'A'
when @id in(2) then 'a'
end
WHEN @type in(2,5) THEN
select
case
when @id in(1) then 'B'
when @id in(2) then 'b'
end
WHEN @type in(3) THEN 'C'
END
解决方案 »
- 请教一下那里出错了
- 为什么提示“必须声明变量 '@ls_table_name'”?
- sql_server 2K 附加数据库问题请教
- 请问一个存储过程自动执行的功能如何实现?
- SQL2005的行列转换PIVOT()的问题望指教.
- 如何删除重复记录(除关键字外),但要留下一条记录
- 用sql建立了一个库和一个表之后如何向里面添加数据?
- 触发器中如何实现
- 把表dep中的dep字段值做为(列)新的字段加到表ZG_TEMP中
- SqlServer2000中关于四舍五入函数 Round 的问题?急急急!!!!!
- 查询分析器中如何知道语句执行的实际时间?
- not in 与 left join 的结果不同,可能是什么原因哦,解决马上给分
CASE
WHEN @type in(1,4,6) THEN
case
when @id in(1) then 'A'
when @id in(2) then 'a'
end
WHEN @type in(2,5) THEN
case
when @id in(1) then 'B'
when @id in(2) then 'b'
end
WHEN @type in(3) THEN 'C'
END
declare @id as int
set @type=3
set @id=1
SELECT
CASE
WHEN @type in(1,4,6) THEN
--select
case
when @id in(1) then 'A'
when @id in(2) then 'a'
end
WHEN @type in(2,5) THEN
--select
case
when @id in(1) then 'B'
when @id in(2) then 'b'
end
WHEN @type in(3) THEN 'C'
END
declare @id as int
set @type=3
set @id=1
SELECT
CASE
WHEN @type in(1,4,6) THEN
--select
case
when @id in(1) then
--如何执行一系列语句呢
when @id in(2) then
--如何执行一系列语句呢
end
WHEN @type in(2,5) THEN
--select
case
when @id in(1) then
--如何执行一系列语句呢'
when @id in(2) then
--如何执行一系列语句呢
end
WHEN @type in(3) THEN
--如何执行一系列语句呢
END
declare @id as int
set @type=3
set @id=1
SELECT
CASE
WHEN @type in(1,4,6) THEN
--select
case
when @id in(1) then
--如何执行一系列语句呢
--update table1 set a='A',b='1'
--update table2 set a='A',b='2'
when @id in(2) then
--如何执行一系列语句呢
--update table1 set a='B',b='2'
--update table2 set a='B',b='3'
end
WHEN @type in(2,5) THEN
--select
case
when @id in(1) then
--如何执行一系列语句呢'
--update table1 set a='C',b='4'
--update table2 set a='C',b='5' when @id in(2) then
--如何执行一系列语句呢
--update table1 set a='C',b='4'
--update table2 set a='C',b='5' end
WHEN @type in(3) THEN
--如何执行一系列语句呢
--update table1 set a='D',b='6'
--update table2 set a='D',b='7' END