4

少年、それは一口です...

文字列からトークンを解析したい。トークンは単語またはフレーズにすることができ、私が望むのは、トークンの出現ごとに文字列に置き換えることです。カーソルを使わずにこれをやりたいです。

元。

declare @str varchar(256) = 'I want this type to be left and of type to be gone. the and a should also be gone of course remains'

create table #Tokens (token varchar(50))
go

insert table (token) values ('of type')
insert table (token) values ('a')
insert table (token) values ('the')
insert table (token) values ('to')
insert table (token) values ('of')
go

私が欲しいのは、文字列で見つかったトークンのリストを '' (空の文字列) に置き換えるインライン関数です。

4

2 に答える 2

3

これをREALテーブルで使用します。

CREATE FUNCTION [dbo].[funStripSpecialCharacters]
(
   @inputString as varchar(max)
)
RETURNS varchar(max)
AS
BEGIN
    select @inputString = REPLACE(@inputString, SpecialCharacter, '') 
      from SpecialCharacters
    RETURN @inputString
END
于 2013-09-18T21:45:46.970 に答える