我的问题是当我输入“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