--写个简单的处理
if exists (select 1 from 表 where 登录编号='登录编号' and 状态 not in('在线','离线')) begin
update 表 set 状态='离线' where 登录编号='登录编号'
end
if exists (select 1 from 表 where 登录编号='登录编号' and 状态='在线') begin
print '该用户已登录'
end
else begin
update 表 set 状态='在线' where 登录编号='登录编号'
print '登录成功'
end