I have a string
@Str1 = '123'
I have another string
@Str2 = '12345'
I need to compare both strings and return 1 if each character in @Str1
have an existence in @Str2
even If the @Str2
is '45132' it must return 1,
If @Str2
is 456 It must return 0
Even If the @Str2 is '45132' it must return 1
I don't suggest use of any functions, because my live table has 1 million rows in it. Possibly I could avoid performance hit.
One quick option is the sign() of charindex(). This will return 1 or 0.
Returns
Using what Zohar ansewered you in How can I insert each character of a string which is not comma delimited to separate row in a table?
you can use:
or
Output using
Output using
Assuming col1 is like @str1 and col2 is like @str2 then your query can be
W/o using any functions and adding for the case
query can be like