I have the next issue, there is table with column data (type - nvarchar), this column can contains any characters, I need selected only data which are numbers or range of numbers, but to ignore white spaces. For example:
declare @tmp table (data nvarchar(192), Result nvarchar(192));
insert into @tmp SELECT '123', '<- valid';
insert into @tmp SELECT ' 123 ', '<- valid';
insert into @tmp SELECT '123-123', '<- valid';
insert into @tmp SELECT ' 123 - 123 ', '<- valid';
insert into @tmp SELECT '123jmj', '<- invalid';
insert into @tmp SELECT '123,5441', '<- invalid';
insert into @tmp SELECT '123,yjyj', '<- invalid';
SELECT * FROM @tmp
The result dataset must contains only valid rows. I can try the next
SELECT * FROM @tmp WHERE data NOT LIKE '%[^0-9]%'
But I got only first row.