T-SQL stored procedure to return google style “suggested” search results

前端 未结 4 1402
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-03 14:06

Ok, using SQL Server 2008. On my web page I have a textbox with jQuery-UI AutoComplete hooked up.

Now I need a stored procedure to search across all columns of a single

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-03 14:26

    Edit: Use a UNION to join separate queries

    SELECT productname FROM foo WHERE productname LIKE '%myinput%'
    UNION
    SELECT productnumber FROM foo WHERE productnumber LIKE '%myinput%'
    UNION
    ...
    

    There is no automatic way to scan all columns unless you use dynamic SQL

提交回复
热议问题