Ms Sql Server中的Substrin(LastIndexOff) [英] Substrin(LastIndexOff) in Ms Sql Server

查看:101
本文介绍了Ms Sql Server中的Substrin(LastIndexOff)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

>有人可以将我指向MSSQL中的一个函数,该函数返回字符串中字符的最后一个索引吗?我正在尝试从返回完整路径的字段中查找基本文件名.

例如.如果db包含行:
C:\ temp \ file1.bat
C:\ temp \ Aug10 \ file2.bat

结果是我想要的:
file1.bat
file2.bat


到目前为止,我想出的唯一解决方案是用文件名创建一个临时表,然后在表上使用update语句递归直到没有更多更新.必须有一个更好的解决方案.

>Hi, can anyone point me to a function in MSSQL that returns the last index of a character in a string? I''m trying to find the base filename from a field that returns the full path.

Eg. if db contained rows:
C:\temp\file1.bat
C:\temp\Aug10\file2.bat

I would want as result:
file1.bat
file2.bat


The only solution I''ve come up with so far is to create a temporary table with the filenames, and recurse using update statements on the table until there are no more updates. There has to be a better solution.

推荐答案

您并不孤单!
您始终可以创建一个函数: http://fahnzmode.com/2011/01/transact-sql- lastindexof-function/ [ ^ ]
You are not alone!
You could always create a function: http://fahnzmode.com/2011/01/transact-sql-lastindexof-function/[^]


这篇关于Ms Sql Server中的Substrin(LastIndexOff)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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