Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy image data type from one table to another

Tags:

sql-server

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?

like image 227
Keith Maurino Avatar asked Mar 03 '09 18:03

Keith Maurino


People also ask

How do I transfer data from one table table to another database?

Steps that need to be followed are:Launch SQL Server Management Studio. Select and right-click on the Source Database, go to Tasks > Export Data. Import/Export Wizard will be opened and click on Next to proceed. Enter the data source, server name and select the authentication method and the source database.

How do I copy data into the same table based on existing data in SQL?

If you want to copy the data of one SQL table into another SQL table in the same SQL server, then it is possible by using the SELECT INTO statement in SQL. The SELECT INTO statement in Structured Query Language copies the content from one existing table into the new table.


2 Answers

You select the records from one table and insert into another. As you do it in the same query, the data doesn't leave the database, so you don't have to store it anywhere.

Example:

insert into SomeTable (SomeId, SomeBinaryField)
select SomeId, SomeBinaryField
from SomeOtherTable
where SomeId = 42
like image 121
Guffa Avatar answered Oct 17 '22 22:10

Guffa


You can make at as complex as you like.

I prefer parsing the same field in the same field using a select statement to copy image data from one table to an other.

Update [Database].[dbo].[DataTableA$Attachment]
SET [Store Pointer ID] = (SELECT [Store Pointer ID]
FROM [Database].[dbo].[DataTableB$Attachment]
WHERE [No_] = '35975') WHERE [No_] = '35975'
like image 1
boekenwurm Avatar answered Oct 17 '22 22:10

boekenwurm