Sql dynamic query With Join And search using like query with multiple column

Sql dynamic query With Join And search using like query with multiple column



declare @keyword varchar(100)
DECLARE @sqlCommand varchar(1000);
SET @keyword='A'

SET @sqlCommand = 'select * from tbl_Employee as E left join tbl_Cities as C on E.CityID='+
' C.Id left join tbl_States as S on E.StateID='+'S.Id left join tbl_Countries as Co on E.CountryID=Co.Id';
set @sqlCommand=@sqlCommand+' where E.Name like ''%'+@keyword+'%'' or'+ 
' E.MiddleName like ''%'+@keyword+'%'' or'+
' E.LastName like ''%'+@keyword+'%'' or'+
' E.FatherName like ''%'+@keyword+'%'' or'+
' E.MiddleName like ''%'+@keyword+'%'' or'+
' E.MotherName like ''%'+@keyword+'%'' or'+
' E.EmailID like ''%'+@keyword+'%'' or'+
' E.AccountNo like ''%'+@keyword+'%'' or'+
' E.AdharCardNo like ''%'+@keyword+'%'' or'+
' E.PanCardNo like ''%'+@keyword+'%'' or'+
' E.Address like ''%'+@keyword+'%'' or'+
' E.PhoneNo like ''%'+@keyword+'%'' or'+
' E.Dob like ''%'+@keyword+'%'' or'+
' E.Gender like ''%'+@keyword+'%'' or'+
' Co.Name like ''%'+@keyword+'%'' or'+
' C.Name like ''%'+@keyword+'%''';

EXEC (@sqlCommand)

No comments:

Post a Comment

Thank You For Your Great Contribution

Featured Post

Sql dynamic query With Join And search using like query with multiple column

Sql dynamic query With Join And search using like query with multiple column declare @keyword varchar(100) DECLARE @sqlCommand va...

Popular Posts