set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[advSearch] ( @createdBy varchar(50) , @subject varchar(200), @details nvarchar(MAX), @againstCompany varchar(100), @headOfficeAdd varchar(200), @deilveryOfficeAdd varchar(250) ) AS BEGIN DECLARE @_s varchar(MAX) DECLARE @_id int select TOP 1 @_id = _id from tbl_User where _userName like '%'+ @createdBy+'%'; SELECT @_id; SET NOCOUNT ON; SET @_s='select * from tbl_Alert where isActive=1'; if @createdBy<>'' BEGIN SET @_s=@_s+' and createdBy ='+@_id; END if @subject<>'' BEGIN SET @_s=@_s+' and subject like ''%'+ @subject+'%'''; END if @details<>'' BEGIN SET @_s=@_s+' and details like ''%'+ @details+'%'''; END if @againstCompany<>'' BEGIN SET @_s=@_s+' and againstCompany like ''%'+ @againstCompany+'%'''; END if @headOfficeAdd<>'' BEGIN SET @_s=@_s+' and headOfficeAdd like ''%'+ @headOfficeAdd+'%'''; END if @deilveryOfficeAdd<>'' BEGIN SET @_s=@_s+' and deilveryOfficeAdd like ''%'+ @deilveryOfficeAdd+'%'''; END exec(@_s) END SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON
SET @_s=@_s+' and createdBy ='+@_id;
SET @_s=@_s+' and createdBy ='+CONVERT(VARCHAR,@_id,0);
SET @_s=@_s+' and createdBy =''' + convert(varchar,@_id) + '''';
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)