1

Topic: Help to make correctly SELECT...

Hello.
How in one SELECT to make check on entrance of an array of values in a string field?
At me while it turned out so:

select t.task_id;
t.task_name;
case
when CHARINDEX (N' operation ', t.descriptions)> 0 then N' other sentence'
when CHARINDEX (N' approaches ', t.descriptions)> 0 then ' the Failure'
when CHARINDEX (N' we take ', t.descriptions)> 0 then N''
when CHARINDEX (N' is not present ', t.descriptions)> 0 then N''
when CHARINDEX (N' answers ', t.descriptions)> 0 then N''
else"
end AS Solution
from (select DISTINCT task_id, task_name from #allInfo) t

If entrance variants will be more, and t.descriptions - there will be a difficult calculated expression SELECT "swells".
As though for once (one function) to fulfill check of all entrances in a line (field)?
I hope clearly explained...

2

Re: Help to make correctly SELECT...

MAULER wrote:

As though for once (one function) to fulfill check of all entrances in a line (field)?

to Create the correspondence table descriptions-Solution...

3

Re: Help to make correctly SELECT...

The matter is that in t.descriptions except the phrases necessary to me,  and other text. As a matter of fact it is correspondence.
Not absolutely I understand, what with this table of correspondence to me to do?! How that to select the correspondence text by words and to do check on entrance in this table?

4

Re: Help to make correctly SELECT...

MAULER wrote:

The matter is that in t.descriptions except the phrases necessary to me,  and other text. As a matter of fact it is correspondence.
Not absolutely I understand, what with this table of correspondence to me to do?! How that to select the correspondence text by words and to do check on entrance in this table?

-- The table, itself you understand, there should be a constant
declare @d2s table (pattern nvarchar (64) not null unique, solution nvarchar (64) not null unique, ord int primary key);
insert @d2s values (N' operation ', N' other sentence ', 0);
select t.task_id;
t.task_name;
Solution = isnull X. Solution, N '? ')
from (select DISTINCT task_id, task_name from #allInfo) t
outer apply (select top (1) * from @d2s as x where t.descriptions like N ' % ' + x.pattern + N ' % ' order by x.ord) as x

5

Re: Help to make correctly SELECT...

MAULER wrote:

The matter is that in t.descriptions except the phrases necessary to me,  and other text. As a matter of fact it is correspondence.

t.descriptions = ' This reptile does not answer! Probably found operation - here and does not approach to phone.'
t.descriptions = ' This reptile, not otherwise, found operation - here and does not approach to phone.'

It is interesting that in similar cases should get in Solution...

6

Re: Help to make correctly SELECT...

Akina wrote:

t.descriptions = ' This reptile does not answer! Probably found operation - here and does not approach to phone.'
t.descriptions = ' This reptile, not otherwise, found operation - here and does not approach to phone.'

It is interesting that in similar cases should get in Solution...

It is killed! ))