Suggest use search procedure

來源: DBDB 2004-06-23 13:32:52 [] [舊帖] [給我悄悄話] 本文已被閱讀: 次 (885 bytes)
I saw your queston and answer.
Just come for a suggestion on the search path.
If you can use a stored procedure instead of
the sql statement in your front end code, that will
benefit system performance and protect your logic.

Here is a quick practice for show, I used pubs..authors
table becasue there is name column in it.

use pubs
go
drop procedure FindName_sp
go
create procedure FindName_sp
( @Name varchar(50)
, @match smallint
)
AS
if @match = 0 /** exact condition **/
Begin
select * from authors
where au_fname = @Name
end

if @match = 1 /** Wildcard condiction **/
Begin
select * from authors
where au_fname like '%' + @Name + '%'
end
return(0)


exec FindName_sp 'John', 0 -- no reuslt
exec FindName_sp 'John', 1 -- one row return

請您先登陸,再發跟帖!

發現Adblock插件

如要繼續瀏覽
請支持本站 請務必在本站關閉/移除任何Adblock

關閉Adblock後 請點擊

請參考如何關閉Adblock/Adblock plus

安裝Adblock plus用戶請點擊瀏覽器圖標
選擇“Disable on www.wenxuecity.com”

安裝Adblock用戶請點擊圖標
選擇“don't run on pages on this domain”