0

I have a table with different columns which included an image. First I have manually entered all the other columns details except the image column. And at last I want to insert an image into that table manually. I tried to use this command but I am failing - it is showing an error:

INSERT INTO Tablename (image column name) 
    SELECT BulkColumn 
    FROM Openrowset( Bulk 'path......', Single_Blob) as img 
    WHERE columnname = 'xxxxx';
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
siva teja
  • 25
  • 7
  • https://stackoverflow.com/questions/1643627/how-to-insert-a-blob-into-a-database-using-sql-server-management-studio – Zeina Jul 31 '17 at 06:23
  • For the sake of clarity, what DB are you using exactly? What is the error message? – Lefty G Balogh Jul 31 '17 at 06:28
  • `image` data types will be removed in a future version of SQL Server. Avoid using this data type in new development work, and plan to modify applications that currently use them. Use `varbinary(max)` instead. [See details here](http://msdn.microsoft.com/en-us/library/ms187993.aspx) – marc_s Jul 31 '17 at 06:33
  • Possible duplicate of [How to insert a blob into a database using sql server management studio](https://stackoverflow.com/questions/1643627/how-to-insert-a-blob-into-a-database-using-sql-server-management-studio) – Priyal Jul 31 '17 at 07:33

1 Answers1

-1

If you have already inserted the details, then you need to update the image column_name:

    UPDATE Tablename
    SET column_name =
    (SELECT * FROM
    OPENROWSET(BULK N'path', SINGLE_BLOB) AS ORS)
Bugs
  • 4,491
  • 9
  • 32
  • 41
Alfaiz Ahmed
  • 1,698
  • 1
  • 11
  • 17