is it possible t开发者_StackOverflow中文版o tell in which column the search string was found, without having to do it with ifs?
if <searchstring> in column1
-- do some stuff here
else if <searchstring> in column2
...
...
i won't post the exact query, as it is too cryptical and too long, but here's a query which does basically the same
select
title,
description
from
position
where
CONTAINS( (title, description), '"manager"' )
You can take help of INFORMATION_SCHEMA.view_name. in this case, like in BOL
SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE IS_NULLABLE = 'NO' ORDER BY DATA_TYPE;
精彩评论