使用参数进行搜索

Using parameters for search

我有 tables customer - customeridphone number, 和 calls - phone numbersdate.

我需要在通话 table 中找到客户的 phone 号码。 现在事情是 - 在调用 table 中 phone 号码可以有不同的方式 -

如果我需要搜索一个值,我会使用 (where phone like %somenumber%') 来实现,但我需要搜索所有数字 - 所以我想我需要用参数来做 - 但我不知道如何...

提前致谢!

您需要 table 作为搜索值。说是:

filtertable(phone varchar(20))

现在您可以加入过滤器table 来电 table 例如:

select * from calls c
join filtertable f on c.phone like '%' + f.phone + '%'

如果您在存储过程中有此逻辑,您可以创建 table 值类型并将过滤器table 传递给您的过程。详情请看这里https://msdn.microsoft.com/en-us/library/bb510489.aspx