Try the below and show us the Print text value: (I could not test it)
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Reddy>
-- Create date: <17/02/2014>
-- Description: <GET BS Attachments>
-- =============================================
ALTER PROCEDURE [dbo].[GetBSAttachments] @StartRowIndex AS VARCHAR(10)
,@MaximumRows AS VARCHAR(10)
,@AddendumNo AS NVARCHAR(254) = NULL
,@ClaimNo AS NVARCHAR(254) = NULL
,@Description AS NVARCHAR(3000) = NULL
,@fileType AS VARCHAR(12)
AS
BEGIN
DECLARE @sqlColumns AS VARCHAR(8000) = ''
DECLARE @sqlCond AS VARCHAR(8000) = ''
DECLARE @sqlCond1 AS VARCHAR(8000) = ''
DECLARE @sqlLimit AS VARCHAR(500) = ''
DECLARE @sqlCount AS VARCHAR(500) = ''
Set @AddendumNo = (Select Case when LEN(LTRIM(RTRIM(@AddendumNo))) = 0 Then NULL Else @AddendumNo End)
Set @Claimno = (Select Case when LEN(LTRIM(RTRIM(@Claimno))) = 0 Then NULL Else @Claimno End)
Set @Description = (Select Case when LEN(LTRIM(RTRIM(@Description))) = 0 Then NULL Else @Description End)
IF (@fileType = 'Attach')
BEGIN
SET @sqlCond1 = 'AND FileExtension <> ''msg'''
END
ELSE IF(@fileType = 'Email')
BEGIN
SET @sqlCond1 = 'AND FileExtension = ''msg'''
END
SET @sqlColumns = 'SELECT * FROM
(Select id,AddendumNo,Description,ClaimNo , ROW_NUMBER() OVER (ORDER BY id) AS RowRank '
SET @sqlCount = 'Select COUNT(*) AS BSAttachTotalCount'
SET @sqlCond = ' FROM EFMS.dbo.Table1 WHERE FileExtension IS NOT NULL ' + @sqlCond1 + '
-- Have to modify this logic
AND (AddendumNo= ISNULL(''' + @AddendumNo + ''',AddendumNo))
AND (Claimno= ISNULL(''' + @Claimno + ''',Claimno))
AND ((''' + @Description + ''' IS NOT NULL AND Description like ''%' + @Description + '%'') OR (''' + @Description + ''' is null and Description=Description''))'
SET @sqlLimit = ' ) AS BSAttachmentsWithRowNumbers WHERE RowRank BETWEEN ''' + CONVERT(NVARCHAR(10), @StartRowIndex) + ''' AND ''' + CONVERT(NVARCHAR(10), @MaximumRows) + ''''
Print @sqlColumns + @sqlCond + @sqlLimit -- To show in the grid by page size
Print 'Another query'
Print (@sqlCount + @sqlCond) -- To get total records count with selection criteria.
END
No comments:
Post a Comment