,怎么把一个表的不同记录的image字段合并成导入另外一个表的一个image字段

高手进,如何把一个表的不同记录的image字段合并成导入另外一个表的一个image字段
把一个表的不同记录的image字段合并成导入另外一个表的一个image字段
多谢!!!

------解决方案--------------------
Update 操作 UPDATETEXT 参数
替换现有数据 指定一个非空 insert_offset 值、非零 delete_length 值和要插入的新数据。
删除现有数据 指定一个非空 insert_offset 值、非零 delete_length 值。不指定要插入的新数据。
插入新数据 指定 insert_offset 值、为零的 delete_length 值和要插入的新数据。

------解决方案--------------------
把一个表的不同记录的image字段合并成导入另外一个表的一个image字段

你这里的合并是什么意思啊?
------解决方案--------------------
我给个简单的例子,多记录合并的话还需LZ自己写存储过程
create table test_table1(id int identity(1,1) primary key,data image)
create table test_table2(id int identity(1,1) primary key,data image)
insert into test_table1 select 0x111111 union all select 0x222222

select * from test_table1

DECLARE @target binary(16),@from binary(16)
insert into test_table2 select data from test_table1 where id=1
select @from=TEXTPTR(data) from test_table1 where id=2
select @target=TEXTPTR(data) from test_table2 where id=1
UPDATETEXT test_table2.data @target null 0 test_table1.data @from

select * from test_table2

drop table test_table1
drop table test_table2

(所影响的行数为 2 行)

id data
---- ---------------
1 0x111111
2 0x222222

(所影响的行数为 2 行)


(所影响的行数为 1 行)

id data
------ ------------
1 0x111111222222

(所影响的行数为 1 行)
------解决方案--------------------
游标的用法如下:
create table test_table1(id int identity(1,1) primary key,data image)
go
create table test_table2(id int identity(1,1) primary key,data image)
go

declare @curorsImage image
declare @AllIamge image
declare cursor_Field cursor for
select data
where data is not null

open cursor_Field
--如果何必我不懂,只告诉你游标怎么使用
fetch next from cursor_Field into @curorsImage

while @@fetch_status=0
begin
fetch next from cursor_Field into @curorsImage
end
close cursor_Field
deallocate cursor_Field
------解决方案--------------------
CREATE TABLE A(pkid int identity(1,1) primary key, myclass nvarchar(16), data image)
INSERT A
select 'A ', 0x111111 union all
select 'A ', 0x222222 union all
select 'A ', 0x333333 union all
select 'A ', 0x444444 union all
select 'B ', 0x111111 union all
select 'B ', 0x222222
GO

-- 处理
SELECT pkid, flag = 0, myclass, data
INTO #
FROM A

DECLARE @pkid int, @myclass nvarchar(16), @myclass1 nvarchar(16),@p1 binary(16), @p2 binary(16),@SP nvarchar(10)

SET @SP = ' '

DECLARE tb CURSOR LOCAL FOR SELECT pkid, myclass, TEXTPTR(data) FROM # ORDER BY myclass, pkid
OPEN tb FETCH tb INTO @pkid, @myclass, @p2

WHILE @@FETCH_STATUS = 0
BEGIN
IF @myclass1 = @myclass
BEGIN
UPDATETEXT #.data @p1 NULL 0 @SP
UPDATETEXT #.data @p1 NULL 0 #.data @p2
END
ELSE
BEGIN
UPDATE # SET flag = 1, @p1 = @p2, @myclass1 = @myclass
WHERE pkid = @pkid
END
FETCH tb INTO @pkid, @myclass, @p2
END

CLOSE tb
DEALLOCATE tb

SELECT id=(SELECT COUNT(1) FROM # WHERE flag = 1 AND myclass <a.myclass) +1,myclass, data