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
 SQL Server 2012 - Select Query for Image Field() ?

Author  Topic 

paramu
Posting Yak Master

151 Posts

Posted - 2013-12-10 : 08:49:30
Hi, Iam using SQL Server 2012.

Table - ChkImgTbl
==========================
Columns Type
==========================
emp_id varchar(20)
employee_image image()

My Insert Query
===============
insert into chkmst values('179',(SELECT * FROM OPENROWSET(BULK 'C:\My_Images\Center1.jpg', SINGLE_BLOB) AS x))

Now I wish to select those columns with image...
How to have a Select Query for image field?


Paramu @ PARANTHAMAN

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2013-12-10 : 12:52:39
You have to use simple select query. SELECT emp_id, employee_image FROM ChkImtTbl But it will show you binary data for image column and NOT as image. But on front end you can show you as picture.
Note: Image data type is obsolete type and VARBINARY(MAX) should be use instead of image data type

--------------------------
http://connectsql.blogspot.com/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-12-10 : 16:40:17
[code]INSERT dbo.ChkMst
(
Col1,
Col2
)
SELECT '179',
i
FROM OPENROWSET(BULK 'C:\My_Images\Center1.jpg', SINGLE_BLOB) AS x(i);
[/code]


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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-11 : 05:30:37
quote:
Originally posted by paramu

Hi, Iam using SQL Server 2012.

Table - ChkImgTbl
==========================
Columns Type
==========================
emp_id varchar(20)
employee_image image()

My Insert Query
===============
insert into chkmst values('179',(SELECT * FROM OPENROWSET(BULK 'C:\My_Images\Center1.jpg', SINGLE_BLOB) AS x))

Now I wish to select those columns with image...
How to have a Select Query for image field?


Paramu @ PARANTHAMAN

if its sql 2012 why not use filetable for toring images?
see
http://visakhm.blogspot.com/2012/07/working-with-filetables-in-sql-2012.html

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

- Advertisement -