Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert Image in to SQL table

Author  Topic 

archana23
Yak Posting Veteran

89 Posts

Posted - 2013-08-07 : 13:41:29
Hi,

I need to insert one person profile with Image in UserProfile Table.

When i see the table UserProfile it has column called IMGNAME ( DataType of varchar(200)) wchich has images like EdwardCyril.jpg, GeorgeClark.jpg etc.

I am able to see only Image name in table not an Image. So how can i add new profile image in to above table.

Can any one please help me on this?

Thank you.

Archana

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-08-07 : 13:45:28
You can only stored the image data in sql server. There is no way to look at the actual image, as you can do with Access.
Here is an idea of how you can insert image data into a table in SQL Server.

See http://weblogs.sqlteam.com/peterl/archive/2007/09/26/Insert-binary-data-like-images-into-SQL-Server-without-front-end.aspx



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

archana23
Yak Posting Veteran

89 Posts

Posted - 2013-08-07 : 13:52:55
Inorder to store Image data in to SQl Server we need to save that particuler image in to one place.

By looking the table existing information How do we know where the images are exist?

Thank you

Archana
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-08 : 01:13:36
you may choose to store it in database or in file system and keep path alone in database. While retrieving read the path from db and use it as a pointer to get actual image from db. But you've to manage the security of physical folders etc yourself if choosing filesystem
In recent version, there's also FILESTREAM datatype available in SQL 2008 R2 and also Filetables in SQL 2012 which can be utilized for the same purpose. This will ensure the security model of SQL server is used and you dont have to worry on security management unless you configure them for Non transact sql access.
In any case the data type of image is deprecated in sql server 2005 onwards so you need to use varbinary(max) instead if you're chooing to store it in db table

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -