I am writing a procedure to overwrite the words that a user automatically disburses on a form and the text I change with the stars if the word is in a lookup database in question.
For this example, suppose Flubber is a harsh word in our absence table and when we have been entered as a word on our word, marking 'Flubber' as inappropriate Required, 'Flabberbart' is OK.
The user enters: I really like watching Flubber.
What I want to do eventually updates the data with the field: I really like to see ******* or some variation in it, probably F **** r.
I have tried to use (and I'm trying to recognize that we have an ineffable word of this level)
< code> announcement @String NVARCHAR (4000) set @String = N'I exactly where MyLookup in (MyWord of Flubber select 'MyWord look like @ string)
but me the following message Meet
Message 7630, Level 15, State 3, Line 4
Full Text Search Status' Really 'Syntax Error' I Really See Flubber Do not like it.
Any assistance will be received gratefully.
EDIT:
With the help of AIGGans, I work well in a complete text index and the following code:
declaration @String NVARCHAR (4000) announced @MatchedWord NVARCHAR (100) announced @ReturnString NVARCHAR (4000) set varString = 'I really convert print MyLookup WHERE FREETEXT (Diissiar, @ string) way of looking Flubber' SELECT varMatchedWord = MyLookup in (VARCHAR (4000 ), @matemented word)
And when whole words are found, then it gives data - right.
On the other side of my question: What is the best way to replace the word 'flabber' with '*******'?
Looking at your new requirements, I'm really going to point you towards the suggestion (Strongly) you use the full text search functionality in SQL Server if it is unavailable, you can take the performance hit to yourself and use the following code:
Select me, @ string as searchfreezes for myself WHERE '.' + @ String + '.' Full example with sample data: DECLARE @MyLookup TABLE (MyWord) '% [^ az]' + MyWord + '[^ az]%'
< p> VARCHAR (20)) in @MyLookup (MyWord) enter a value ( 'Flubber') announced @String nVARCHAR (4000) set @String = N'I exactly as where selected '@MyLookup MyWord, @String SearchPhrase Like watching flubbers'. '+ @ String +'. ' Like '% [^ A-z]' + + MyWord + '[^ a-z]%' SET @ string = n 'is actually seeing Flubber. 'Pick My Myers,' from Strings A S Search @ Where from Mylookup. ' + @ String + '.' Like '% [^ A-z]' 'Myvar +' [^ a-z]% 'SET @ string = n' is actually like watching flabber, is it weird? ' Choose my myers, @from @silkup from @yilukup. + @ String + '.' Like '% [^ az]' + MyWord + '[^ az]%' set @String = N'I actually select 'MyWord like watching Flubber movie, @String as where SearchPhrase from @MyLookup' . '+ @ String +'. ' Like '% [^ A-z]' + + MyWord + '[^ a-z]%' SET @ string = n 'is actually like seeing Flubber! 'Pick My Myers,' from Strings A S Search @ Where from Mylookup. ' + @ String + '.' Like '% [^ A-Z]' + MyWord + '[^ A-Z]% "set @String = N'I actually select' like watchingFlubber in MyWord, @MyLookup the @String where 'as SearchPhrase. '+ @ String +'. ' '% [^ Az]' + 'MyWord +' [^ az] ''
Edit: Talk about the moving target ... I have taken the code from your comment (complete) Using the text) and the return string was printed to replace the word with the asterisk.
Note that if the word shows the same search string multiple times, then it will replace all the instances. I do not have access to an example with full text search enabled, so you have to confirm that it is working as expected.
DECLARE @ string NVHAR (4000) DECLARE @MatchedWord NVARCHAR (100) Announcement @ReturnString NVARCHAR (4000) set @String = 'I really like seeing flubber' @MatchedWord = MyWord MyLocup WHERE FREETEXT (DESCR, String) Print Convert (VARCHAR (4000), @metrated word) from @ReturnString = REPLACE (@String, MyWord, Repeat ('*', LEN (MyWord)) Print Convert (VARCHAR (4000) ), @ Return string)
Comments
Post a Comment