Click here to Skip to main content
15,914,795 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using sql server 2008 R2.

I need to insert an image through sql cmd ?

my table structure is
SQL
SELECT TOP 1000 [AddressID]
[Image]
FROM [xxx].[dbo].[tblAddress]


how can i insert an image where AddressID='1' ?
Posted
Updated 9-Sep-15 23:44pm
v2

do you even google?

Store or Save images in SQL Server[^]

Please use the search facilities provided.

These are the rules for new posts. It's right there when you post a question
A few simple rules when posting your question.
Be courteous. Everyone here helps because they enjoy helping, not because it's their job.
Have you searched or Googled for a solution?
Be specific! eg "How do I change the dialog colour?" instead of "My code doesn't work. Help?"
Tag your question appropriately.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
Do not remove or empty a message if others have replied.
 
Share this answer
 
v2
Comments
Member 11367931 10-Sep-15 7:01am    
Msg 4861, Level 16, State 1, Line 3
Cannot bulk load because the file "C:\Users\system 1\Desktop\Desk\xxx.jpg" could not be opened. Operating system error code 3(The system cannot find the path specified.).

am hanging on this error i dont know how to solve this.. so only i posted this question
Andy Lanng 10-Sep-15 7:04am    
Ah - you should have included that detail in your question.

Ok - Sounds like your trying to push a file direct from the operating system into the database. Try not to do that. Use another program (like c#) to load the image and insert it. C# can interact with the file system much easier that sql can
Please try following query
SQL
UPDATE [dbo].tblAddress Set [Image] =
(SELECT MyImage.* from Openrowset(Bulk
'C:\Image.bmp', Single_Blob) MyImage)
Where AddressID=1



For more please check following links

https://msdn.microsoft.com/en-us/library/ms190312.aspx[^]

https://technet.microsoft.com/en-us/library/Aa276850%28v=SQL.80%29.aspx[^]

https://www.mssqltips.com/sqlservertip/1643/using-openrowset-to-read-large-files-into-sql-server/[^]

With Regards,
Manoj
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900