本文介绍了检索数字和特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我已经记录了"20112312438_AjaxURLS.txt_123546675",在其中仅需要在网格视图中显示"AjaxURLS.txt".将替换所有数字和特殊字符的查询是什么?请帮助
Hi all,
I have record "20112312438_AjaxURLS.txt_123546675" where I need to display in grid view only "AjaxURLS.txt" .What will be the query for that to replace all number and special character ? please help
推荐答案
DECLARE @InputString NVARCHAR(MAX)
DECLARE @Delimiter NVARCHAR(40)
DECLARE @Pos INT
DECLARE @NextString NVARCHAR(40)
SET @InputString = '20112312438_AjaxURLS.txt_123546675'
SET @Delimiter = 1
SET @Pos = 1
SET @InputString = @InputString + @Delimiter
CREATE TABLE #Results(Tokens NVARCHAR(MAX))
WHILE (@pos<>0)
BEGIN
SET @NextString = replace(@inputstring,@delimiter,'')
set @delimiter=@delimiter+1
INSERT INTO #Results VALUES (@NextString)
update #results set tokens=@nextstring
SET @InputString = replace(@NextString,'_','')
SET @pos = charindex(@Delimiter,@InputString)
END
SELECT distinct replace(tokens,'0','') FROM #Results
DROP TABLE #Results
这篇关于检索数字和特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!