1
declare
@cc
char
(
10
),
@i
int
,
@aa
char
(
20
),
@bb
int
2![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
select
@cc
=
'
年月日
'
,
@aa
=
'
2-36-54-1
'
,
@bb
=
1
,
@i
=
1
/**/
/* 把数字中的—替换成年月日 */
3
while
@bb
!=
0
4
begin
5
select
@bb
=
charindex
(
'
-
'
,
@aa
)
if
@bb
=
0
break
else
select
@aa
=
stuff
(
@aa
,
@bb
,
1
,
substring
(
@cc
,
@i
,
1
))
6
set
@i
=
@i
+
1
7
end
8
select
@aa
![None.gif](/Images/OutliningIndicators/None.gif)
2
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](/Images/OutliningIndicators/ContractedBlock.gif)
3
![None.gif](/Images/OutliningIndicators/None.gif)
4
![None.gif](/Images/OutliningIndicators/None.gif)
5
![None.gif](/Images/OutliningIndicators/None.gif)
6
![None.gif](/Images/OutliningIndicators/None.gif)
7
![None.gif](/Images/OutliningIndicators/None.gif)
8
![None.gif](/Images/OutliningIndicators/None.gif)