0

guys!

I don't know how to select objects that do not contain suffixes. I declare input table of suffixes

  @suffixes  dbo.tvp_stringArray READONLY

And then I'm selecting my objects

SELECT [Object]
FROM [myUsers]
WHERE [Object] IS NOT LIKE (SELECT suffix FROM suffixes)

How to add '%' to the selected suffix?

Matt
  • 109
  • 12

2 Answers2

0

try this :

SELECT [Object]
FROM [myUsers]
WHERE [Object] IS NOT LIKE (SELECT  Cast(suffix as nvarchar(1000)) + '%' FROM suffixes)

Ref link

Community
  • 1
  • 1
BhushanK
  • 1,205
  • 6
  • 23
  • 39
0

As others have pointed out, you can concatenate the % to the suffix when using the LIKE operator.

But to take into account the fact that you only want the objects that does not match any of the suffixes, assuming there are more than one, you could add NOT EXISTS like this:

SELECT *
FROM MyUsers 
WHERE NOT EXISTS (SELECT 1 FROM Suffixes WHERE MyUsers.Object LIKE '%' + suffix );

SQL Fiddle

larsts
  • 451
  • 5
  • 12