Пожалуйста, подтвердите, если это работает для вас:
declare @tempTable table (hashtag varchar(Max))
declare @asdf varchar(100) = '#Hello world! Need to #filter the #tag'
declare @i integer =0
declare @length integer = (select len(@asdf)-len(replace(@asdf,'#','')))
while (select @i)< @length
begin
insert into @tempTable select substring(@asdf,charindex('#', @asdf),charindex(' ', @asdf))
set @asdf = ltrim((select substring(substring(@asdf,charindex('#', @asdf),len(@asdf)),charindex(' ', @asdf)+1,len(@asdf))))
set @i = @i+1
end
select HashTag from @tempTable