Home > SQL > Copy Image Data Type From One Table To Another

Copy Image Data Type From One Table To Another


tabel karyawan dan tabel karyawan lama
isi kolomnya sama yaitu nik dan sidik_jari,
nik tipedatanya char(10), sidik_jari tipe datanya image


DECLARE @nik char(10)
declare @sidik_jari varbinary(16)
declare @sidik_jari_dest varbinary(16)
DECLARE @ckaryawan CURSOR

SET @ckaryawan = CURSOR FOR
select nik,TEXTPTR(sidik_jari) from karyawan_lama 
	OPEN @ckaryawan
	FETCH NEXT FROM @ckaryawan
	INTO @nik,@sidik_jari
	WHILE @@FETCH_STATUS = 0
	BEGIN		
		select @sidik_jari_dest=textptr(sidik_jari) from karyawan where nik=@nik 
		updatetext karyawan.sidik_jari @sidik_jari_dest 0 0 karyawan_lama.sidik_jari @sidik_jari
		FETCH NEXT FROM @ckaryawan
		INTO @nik,@sidik_jari
	END

CLOSE @ckaryawan
DEALLOCATE @ckaryawan


Categories: SQL Tags: , , , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: