select t.xx, (case
when t.xx = '100006' then
'OK'
when t.xx= '100005' then
'NO'
else
'OOOO'
end ) AS item_id
from aa t
when t.xx = '100006' then
'OK'
when t.xx= '100005' then
'NO'
else
'OOOO'
end ) AS item_id
from aa t
解决方案 »
- 哪位朋友帮忙翻译一下!
- 请问怎么用在本地用查询分析器连接远程数据库,再把远程数据导出到本地
- 如何将SQL2000 中的表及表中的数据生成脚本文件
- 一个数据库报表问题
- 还是关于SQL安装的问题?
- 请问安装SQL Server 2000 SP2前要安装SQL Server 2000 SP1吗?
- sql问题:怎么出现想要得效果?
- 某字段数据形式为a$b$c
- 数据库PING的问题?(尽我所能给分)
- 从库中取图片 每页纸打8个人的 姓名、性别、照片 并要求连续打印 如何用PB实现(急在线)
- SQL-SERVER的数据同步可以在2台SQL-SERVER之间同步数据,那有什么方法可以在ACCESS和SQL-SERVER之间同步数据呢?我想把SQL-SERVER的数据同
- 执行xp_cmdshell时发生错误。。。。。。。。。。
when 'B' then 'F2'
else 'T'
end
SELECT 'F1'
ELSE IF B
SELECT 'F2'
ELSE
BEGIN
INSERT INTO 表
.
.
END
SELECT 'F1'
ELSE IF B
SELECT 'F2'
ELSE
BEGIN
INSERT INTO 表
.
.
END
大概思路是传入用户ID 级别 时间字符串
先判断 表内是不是有相同时间字符串
有 则返回F1在判断该用户在表内的记录数 超过数量
返回F0以上两个条件通过
插入记录---------------
CREATE PROCEDURE notic_add@id VarChar (50),
@ulevel int,
@notic_time VarChar (50),
@notic_com VarChar (50),
@mesage VarChar (10)='' outputAS
declare @countid intif exists (select * from 表 where notic_time=@notic_time and notic_user=@id)
begin
set @mesage ='f0'
endelse begin
insert into 表
(notic_time,notic_com,notic_user )values (@notic_time,@notic_com ,@id)
set @mesage ='t'
end
GO
@ulevel int, --级别
@notic_time VarChar (50), --时间字符串
@notic_com VarChar (50),
@mesage VarChar (10)='' output
ASdeclare @countid intif exists (select * from 表 where notic_time=@notic_time and notic_user=@id)
select @mesage ='f1'
select @countid = select count(*) from 表 where notic_user=@idif @countid >数量
select @mesage ='f0'
else
begin
insert into 表(notic_time,notic_com,notic_user )
values (@notic_time,@notic_com ,@id)
set @mesage ='t'
end
GO
@id VarChar (50), --用户id
@ulevel int, --级别
@notic_time VarChar (50), --时间字符串
@notic_com VarChar (50),
@mesage VarChar (10)='' output
AS
declare @countid intdeclare @countid intif exists (select * from 表 where notic_time=@notic_time and notic_user=@id)
begin
set @mesage ='f0'
end
set @countid=(select count(id) from 表where notic_user=@id)
if @countid>=(@ulevel*2)
set @mesage ='f1'
else begin
insert into lsb_member_notic (notic_time,notic_com,notic_user )values (@notic_time,@notic_com ,@id)
set @mesage ='t'
end
GO以上代码
第一条判断没起作用
当@mesage ='f0' 不会向下执行
当if exists (select * from 表 where notic_time=@notic_time and notic_user=@id)
即 可以录入相同内容到notic_time字段
而本意是不可以录入相同内容到该字段