如何从保存在SQL中的字节中检索图像名称 [英] How to retrieve image name from byte which saved in sql

查看:89
本文介绍了如何从保存在SQL中的字节中检索图像名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨Frds,
我将图像以字节(数据类型为图像)的形式保存在sql server 2005中,而下载时我需要知道图像的扩展名,如.jpg或.gif

Hi Frds,
I am saving my image in sql server 2005 as byte(datatype as Image),While downloading i need to know the extension of the image as like .jpg or .gif

推荐答案

WHEN LEFT(convert(varbinary(8), IDOC),2)=0x424D THEN 'BMP'
 WHEN LEFT(convert(varbinary(8), IDOC),2)=0xFFD8 THEN 'JPG'
 WHEN LEFT(convert(varbinary(8), IDOC),2)=0x4749 THEN 'GIF'
WHEN LEFT(convert(varbinary(8), IDOC),2)=0x4920 THEN 'TIF' 


检查一下.

http://social.msdn.microsoft.com/论坛/en-US/sqldataaccess/thread/24db1dc1-f12b-44b1-8ff3-6bc287a26791 [ http://www.garykessler.net/library/file_sigs.html [


Check this.

http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/24db1dc1-f12b-44b1-8ff3-6bc287a26791[^]

and this.

http://www.garykessler.net/library/file_sigs.html[^]


这篇关于如何从保存在SQL中的字节中检索图像名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆