博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
好久没写代码,今天刚刚给客户写了点
阅读量:5222 次
发布时间:2019-06-14

本文共 1636 字,大约阅读时间需要 5 分钟。

真郁闷,这家客户自己写外挂把我们的数据库完整性给破坏了,还要我们修复
icon18.gif
唉,贴出来做个纪念吧......
None.gif
declare
 
@cardnum
 
nvarchar
(
80
)
None.gif
declare
 
@personid
 
nvarchar
(
80
)
None.gif
declare
 
@accessionstate
 
int
None.gif
declare
 
@personid222
 
nvarchar
(
80
)
None.gif
declare
 _cor 
cursor
 
for
 
None.gif
select
 cardnum 
as
 cn 
from
 psnaccount 
None.gif
where
 cardnum 
<>
''
 
group
 
by
 cardnum
None.gif
having
 
count
(cardnum)
>
1
  
order
 
by
 cn 
desc
 
None.gif
None.gif
open
 _cor
None.gif
FETCH
 
NEXT
 
FROM
 _cor 
INTO
 
@cardnum
None.gif
None.gif   
WHILE
 
@@FETCH_STATUS
 
=
 
0
None.gif   
BEGIN
None.gif
None.gif      
PRINT
 
'
  
'
 
+
 
@cardnum
None.gif    
set
 
@personid
 
=
 
''
None.gif    
set
 
@personid222
 
=
 
''
ExpandedBlockStart.gifContractedBlock.gif    
/**/
/* 查询出离职人员编号  */
None.gif    
declare
 personid_cursor 
cursor
 
for
None.gif    
select
 
top
 
1
 personid,accessionstate 
from
 psnaccount 
where
 cardnum 
=
 
@cardnum
 
and
 accessionstate 
=
 
4
None.gif    
open
 personid_cursor
None.gif    
FETCH
 
next
 
from
 personid_cursor 
into
 
@personid
,
@accessionstate
None.gif        
WHILE
 
@@FETCH_STATUS
 
=
 
0
None.gif           
BEGIN
None.gif            
fetch
 
next
 
from
 personid_cursor 
into
 
@personid
,
@accessionstate
None.gif        
END
None.gif    
close
 personid_cursor
None.gif    
deallocate
 personid_cursor
ExpandedBlockStart.gifContractedBlock.gif    
/**/
/* END 查询出离职人员编号  */
None.gif
ExpandedBlockStart.gifContractedBlock.gif    
/**/
/* 查询出在职人员编号 */
None.gif    
declare
 personid_cursor 
cursor
 
for
None.gif    
select
 
top
 
1
 personid,accessionstate 
from
 psnaccount 
where
 cardnum 
=
 
@cardnum
 
and
 accessionstate 
=
 
2
None.gif    
open
 personid_cursor
None.gif    
FETCH
 
next
 
from
 personid_cursor 
into
 
@personid222
,
@accessionstate
None.gif        
WHILE
 
@@FETCH_STATUS
 
=
 
0
None.gif           
BEGIN
None.gif            
fetch
 
next
 
from
 personid_cursor 
into
 
@personid222
,
@accessionstate
None.gif        
END
None.gif    
close
 personid_cursor
None.gif    
deallocate
 personid_cursor
ExpandedBlockStart.gifContractedBlock.gif    
/**/
/* END 查询出在职人员编号  */
None.gif
ExpandedBlockStart.gifContractedBlock.gif    
/**/
/* 更新编号 */
None.gif    
if
 
@personid
 
<>
''
 
and
 
@personid222
 
<>
''
None.gif    
BEGIN
None.gif        
UPDATE
 atdtimecarddata 
set
 PERSONID 
=
 
@personid222
 
where
 personid 
=
 
@personid
 
and
 receivedate 
>=
'
2005-09-12
'
None.gif    
END
ExpandedBlockStart.gifContractedBlock.gif    
/**/
/* END 更新编号 */
None.gif
None.gif      
FETCH
 
NEXT
 
FROM
 _cor 
INTO
 
@cardnum
None.gif   
None.gif   
END
None.gif
CLOSE
 _cor
None.gif
DEALLOCATE
 _cor

转载于:https://www.cnblogs.com/minbear/archive/2005/09/28/246084.html

你可能感兴趣的文章