if exists
Posted Better_ZYQ
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了if exists相关的知识,希望对你有一定的参考价值。
string strSql = @"
--项目已立项/立项审批中
if exists(select 1 from FFS_PROJECT where [email protected]_id and recordstatus in(‘Approved‘,‘Approvaling‘))
begin
select 1
return
end
--项目已有放款申请
if exists(
select 1 from FFS_PROJECT a
inner join FFS_PROJECTAPPLY b on a.guid=b.PROJECTID
where [email protected]_id
)
begin
select 2
return
end
--不是该业务员对应的客户不以不能注销
if not exists(
select 1 from FFS_PROJECT a
inner join FFS_CustomerRefsaler b on a.customerid=b.customer_id
where [email protected]_id and [email protected]_id and b.recordstatus=‘A‘
)
begin
select 3
return
end
select 0";
//法务部审批时才有编辑数据权限
string strSql = string.Format(@"
if exists(
select 1 from FFS_ApproverRoleUser a
inner join FFS_ApproverRole b on a.role_id=b.guid
where b.role_name In (‘风控总监‘,‘风控专员‘) and a.staff_id=‘{0}‘ and a.recordstatus=‘A‘ and b.recordstatus=‘A‘
)
and exists(select 1 from if_wf_prcs a
inner join if_wf_activity b on a.ACTIVITY_ID=b.GUID
where a.INST_ID=‘{1}‘ and a.USER_ID=‘{0}‘ and isnull(a.COMPLETE,0)=0 and b.NAME in (‘风控总监项目立项初审‘,‘风控项目立项初审‘)
)
select 1
else
select 0", Token.Current.Id, did);
以上是关于if exists的主要内容,如果未能解决你的问题,请参考以下文章