sql - exe dbo.SearchAllTables '12345678' - ? how do we search for multiple text? -
exe dbo.searchalltables '12345678'
i need query search multiple items; items 12345678, 78945641, 14725836
in tables in database. above query works single text search.
i think have clue in stored procedure @find
input this:
set @query = @query + 'where [value] ''%' + @find + '%''' exec(@query)
now input @find = '12345678, 78945641, 14725836'
, should change code of these:
if want find exact values:
set @query = @query + 'where [value] in (''' + replace(@find, ',', ''',''') + ''')' exec(@query)
if want find containing values:
set @query = @query + 'where [value] ''%' + replace(@find, ',', '%'' or [value] ''%') + '%''' exec(@query)
Comments
Post a Comment