-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateText.sql
More file actions
42 lines (30 loc) · 825 Bytes
/
UpdateText.sql
File metadata and controls
42 lines (30 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*TEXT TO FIND in BLOB*/
declare @otxt varchar(100)
set @otxt = 'http://192.168.1.61/his_localgov/'
DECLARE CURS CURSOR LOCAL FAST_FORWARD
FOR
SELECT p_news_id,
textptr(story),
charindex(@otxt, story)-1
FROM tblnews
WHERE charindex('http://192.168.1.61/his_localgov/', story) <> 0
/**text to replace in BLOB**/
declare @ntxt varchar(50)
set @ntxt = ''
declare @txtlen int
set @txtlen = len(@otxt)
declare @ptr binary(16)
declare @pos int
declare @id int
open curs
fetch next from curs into @id, @ptr, @pos
while @@fetch_status = 0
begin
UPDATETEXT tblnews.story @ptr @pos @txtlen @ntxt
fetch next from curs into @id, @ptr, @pos
end
close curs
deallocate curs
SELECT COUNT(*)
FROM tblnews
WHERE charindex('http://192.168.1.61/his_localgov/', story) <> 0