我的问题是,当我输入像"XXX“这样的文本并点击”搜索“按钮时,它只显示"XXX”的记录。但我想展示所有的记录,大写和小写的"XXX“。然后我尝试freetext,但是它显示了“在关键字‘Freetext’附近不正确的语法”。
有人能告诉我原因吗.
我用下面的代码进行多次搜索.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[sp_searchdetails]
@customervendortype varchar(30)=Null,
@customervendorid varchar(30)=Null,
@customervendorname varchar(30)=Null,
@state varchar(30)=Null,
@city varchar(30)=Null
AS
BEGIN
if @customervendortype is not null and len(@customervendortype)=0 set @customervendortype = null
if @customervendorid is not null and len(@customervendorid)=0 set @customervendorid = null
if @customervendorname is not null and len(@customervendorname)=0 set @customervendorname = null
if @city is not null and len(@city)=0 set @city = null
if @state is not null and len(@state)=0 set @state = null
SELECT CustomerVendorDetails.customervendorid,CustomerVendorAddressDetails.customervendorname, CustomerVendorAddressDetails.doorno, CustomerVendorAddressDetails.street,
CustomerVendorAddressDetails.city, CustomerVendorAddressDetails.state, CustomerVendorAddressDetails.country,
CustomerVendorAddressDetails.pincode, CustomerVendorDetails.decidingauthority,
CustomerVendorDetails.landlineno1, CustomerVendorDetails.landlineno2, CustomerVendorDetails.faxno, ContactPersonDetails.contactno,
ContactPersonDetails.designation
FROM
CustomerVendorDetails INNER JOIN
CustomerVendorAddressDetails ON CustomerVendorDetails.customervendorid = CustomerVendorAddressDetails.customervendorid INNER JOIN
ContactPersonDetails ON CustomerVendorAddressDetails.customervendorid = ContactPersonDetails.customervendorid
WHERE
(@customervendortype is null or CustomerVendorDetails.customervendortype like @customervendortype) and (@customervendorid is null or CustomerVendorDetails.customervendorid like @customervendorid) and Freetext (@customervendorname is null or CustomerVendorDetails.customervendorname like @customervendorname ) and Freetext (@city is null or CustomerVendorAddressDetails.city like @city)and Freetext (@state is null or CustomerVendorAddressDetails.state like @state)
END发布于 2010-11-30 10:55:24
在freetext函数中,您不需要做一些操作,只需描述列和参数。参见MSDN (描述变量使用的第二个示例)
https://stackoverflow.com/questions/4310827
复制相似问题