会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
我的选择,我的最爱,我的希望,我的追求,我的奋斗。
因为选择了,所以爱上了
数据处理
1
--
字符处理!
2
3
declare
@str
varchar
(
100
)
4
declare
@i
int
5
declare
@substr
varchar
(
100
)
6
declare
@length
int
7
declare
@id
int
8
declare
find_baby_uid
cursor
for
9
select
ID,字段2
from
a1
10
open
find_baby_uid
11
fetch
next
from
find_baby_uid
into
@id
,
@str
12
while
@@fetch_status
=
0
13
begin
14
set
@length
=
len
(
@str
)
15
print
@id
16
print
@str
17
set
@i
=
patindex
(
'
%/%
'
,
@str
)
18
if
(
@i
=
0
)
19
begin
20
set
@substr
=
@str
21
end
22
else
23
begin
24
set
@substr
=
substring
(
@str
,
@i
+
1
,
@length
)
25
end
26
update
notebook
set
字段3
=
@substr
where
ID
=
@id
27
fetch
next
from
find_baby_uid
into
@id
,
@str
28
end
29
close
find_baby_uid
30
deallocate
find_baby_uid
31
32
--
表中一个字段有很多重复记录,相同的记录保留一条
33
DECLARE
Cursor_Title
CURSOR
FOR
SELECT
distinct
字段3
FROM
notebook
34
OPEN
Cursor_Title
35
declare
@str
varchar
(
255
)
36
FETCH
NEXT
FROM
Cursor_Title
Into
@str
37
WHILE
@@FETCH_STATUS
=
0
38
BEGIN
39
insert
into
a1
select
top
1
*
from
notebook
where
字段3
=
@str
40
FETCH
NEXT
FROM
Cursor_Title
Into
@str
41
END
42
CLOSE
Cursor_Title
43
DEALLOCATE
Cursor_Title
44
45
46
47
48
posted on
2006-12-05 09:47
彭灿明
阅读(
154
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
导航
博客园
首页
新随笔
联系
订阅
管理
公告