搜索的存储过程是什么 [英] what is the storedproc for search
本文介绍了搜索的存储过程是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用参数进行搜索的存储过程是什么,例如:-如果用户在文本框中搜索"John Smith"的内容并输入"Smith John"的任何一种方式,则必须返回"John Smith",而不是null .
这是我的存储过程":如果我用任何一种方法搜索,它都将返回null.
what is the storedprocedure for searching using parameter eg:-if a user what to search ''John Smith'' in a textbox and enters either way ''Smith John'' it must return ''John Smith'' not null.
This is My Storedprocedure: and if i search either way it returs null.
ALTER PROCEDURE [dbo].[sp.Search]
@Search varchar(255)
AS
BEGIN
SET NOCOUNT ON;
SELECT Description from ['Portal Catalogue$']
where Description Like '%'+@Search+'%'
END
推荐答案
']] 其中说明类似 ' %' + @ Search + ' %' END
'] where Description Like '%'+@Search+'%' END
我向您介绍您上次询问此问题时得到的答案:如何使用存储过程在SQL Server中搜索文本 [ ^ ]
阅读您获得的链接并为自己学习一些东西...
I refer you to the answers you got to the last time you asked this question: How do you search text in SQL server using Storedprocedure[^]
Read the links you were given and learn something for yourself...
尝试一下....
try this....
ALTER PROCEDURE [dbo].[sp.Search]
@Search varchar(255)
AS
BEGIN
SET NOCOUNT ON;
declare @strpart1 varchar(255)
select @strpart1 = SUBSTRING( @Search,CHARINDEX(' ', @Search,1),(LEN( @Search) - CHARINDEX(' ', @Search,1) + 1))
SELECT Description from tablename
where Description Like '%'+@strpart1+'%'
END
希望对您有帮助
hope this helps
这篇关于搜索的存储过程是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文