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
I have create a sample SQL that will return google style search result. You can try this T-SQL. You can also add more than one table column searching criteria.
ALTER PROC [dbo].[USP_GetDoctorLookupList]
(
@SearchText varchar(50),
@ItemCount int
)
AS
BEGIN
SET @SearchText = RTRIM(@SearchText) + '%'
BEGIN
SELECT TOP (@ItemCount) *
FROM
(
SELECT
CASE
WHEN RTRIM(LTRIM(d.cdocname)) LIKE @SearchText then 1
WHEN RTRIM(LTRIM(d.cdeano)) LIKE @SearchText then 2
END OrderBy,
d.docid_PK,
d.cdocname,
d.cdeano
FROM doctor d
WHERE
(d.cdocname LIKE @SearchText
OR d.cdeano LIKE @SearchText
)
) Doc ORDER BY OrderBy, cdocname
END
END