如何通过从数据库删除文件扩展名来检索列值 [英] How to retrieve the column values by removing the extensions of filename from databse

查看:69
本文介绍了如何通过从数据库删除文件扩展名来检索列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在数据库中保存一些上载的文件名.其扩展名为..,另一些仅具有文档名.

因此,在检索记录时,我想检查值中是否存在任何扩展名,例如(.docx)etc,请检查并删除存储过程本身中的值.


Sql Server 2008中有什么办法吗?


谢谢
yashoda

I am saving some uploaded file name in database.. its saving with the file extension.. and some only with document name.

So while retrieving the records i want to check if any extension like (.docx)etc is existing in the value, check and remove the value in stored procedure itself.


Is there any way in Sql Server 2008


Thank you,
yashoda

推荐答案

立即执行此操作,将[Path]替换为您的字段名称,并将[Files]替换为您的表名称

Give this a go, replace [Path] with the name of your field and [Files] with the name of your table

SELECT
    CASE WHEN CHARINDEX('.',REVERSE([Path])) > 1 THEN LEFT([Path], LEN([Path]) - CHARINDEX('.',REVERSE([Path]))) ELSE [Path] END AS FileNameWithoutExtension
FROM
    [Files]


这篇关于如何通过从数据库删除文件扩展名来检索列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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