if i put something
DECLARE @Query VARCHAR(8000)
SET @Query = 'select * from subscriber
where sbs_userid = ' + cast(@UserID as varchar) + '
and SBS_Status in (select statusFlag from #tmpStatusFlag)
and SBS_SourceFlag in (select sourceFlag from #tmpSourceFlag)'
IF (@FirstName !='')
SET @Query = @Query + ' and SBS_FirstName like ''%' + @FirstName + '%'''
IF(@LastName !='')
SET @Query = @Query + ' and SBS_LastName like ''%' + @LastName + '%'''
IF(@Phone !='')
SET @Query = @Query + ' and SBS_WorkPhone like ''%' + @Phone + '%'''
IF(@EmaiAdderess !='')
SET @Query = @Query + ' and SBS_EmailAddress like ''%' + @EmaiAdderess + '%'''
IF(@City !='')
SET @Query = @Query + ' and SBS_City like ''%' + @City + '%'''
IF(@SubListId !='-1')
SET @Query = @Query + ' and SBS_SubListId like ''%' + @SubListId + '%'''
SET @Query = @Query + ' order by SBS_CreationDate desc'
EXEC (@Query)
in my stored procedure .
my question is still i get the benefits of stored procedure or is it a wrong approach
i never use this but my Team Leader used this to speed up the stored proceure . is it ok ?
EDITED
IF we use sp_executesql instead of exec then we can take the benefits of stored procedure.and is this ok with this ?