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

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -