Copy image data type from one table to another

How do you copy an image data type (or varbinary (max)) from one table to another in SQL Server, without having to save the data to a file first?

+3
source share
3 answers

You select records from one table and insert into another. As you do this in the same query, the data does not leave the database, so you do not need to store it anywhere.

Example:

insert into SomeTable (SomeId, SomeBinaryField)
select SomeId, SomeBinaryField
from SomeOtherTable
where SomeId = 42
+8
source

You can make it as difficult as possible.

I prefer parsing one field in one field using the select statement to copy image data from one table to another.

Update [Database].[dbo].[DataTableA$Attachment]
SET [Store Pointer ID] = (SELECT [Store Pointer ID]
FROM [Database].[dbo].[DataTableB$Attachment]
WHERE [No_] = '35975') WHERE [No_] = '35975'
+1
source

insert SELECT, :

declare @t1 table (t1 image)
declare @t2 table (t2 image)
insert into @t2 select t.t1 as t2 from @t1 as t

INSERT:

http://msdn.microsoft.com/en-us/library/ms174335.aspx

0

Source: https://habr.com/ru/post/1704147/


All Articles