How to compose LIKE in T-SQL to show all rows except those that contain ":", "-", "~"?

I have a SQL Server engine in which I have an entry with a filter clause. I need to get this offer is displayed for all lines except those that contain : , - , ~ .

My request:

SELECT 1 
WHERE '' LIKE '%[^:-~]%'

It does not work - it shows zero lines. I also try this:

SELECT 1 
WHERE 'aa:a' LIKE '%[^:-~]%'

And it shows as result 1, which is not the desired result.

Is there any way to handle this?

Note: the expression after likemust be a string that will be stored inside the table field (for exmaple: it '%[^:-~]%'will be used as LIKE x.fldFilter)

EDIT: SQL Server. . Format. , Format.

:

DECLARE @value AS VARCHAR(1000) = 'aaa:aa';

SELECT 1 FROM dbo.ParameterDefinitions X WHERE @value LIKE X.[Format];

X.[Format] '%[^:-~]%'.

, 1, , .

, 'aaa:aa' ' ', . (''), .

, '' , . , '' ?

+4
1

, SQL Server .

, ^

SELECT 1    
WHERE '' NOT LIKE '%[:-~]%'

1

SELECT 1 
WHERE 'aa:a' NOT LIKE '%[:-~]%'

0

EDIT:

'' LIKE '%[^:-~]%'

[^:-~] ,

'aa:a' LIKE '%[^:-~]%'

% - 0 , [^:-~] 'a', % .

regex [^:-~]*, SQL Server .

, , - '%[:-~]%' .

+2

Source: https://habr.com/ru/post/1608795/


All Articles