Aug 19, 2014

SQL get remain data on record

ALTER procedure [dbo].[GetData_Remain]

@StringData nvarchar(max),
@Start int,
@End int,
@QueryFilter nvarchar(max) = ''

As
Begin

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

declare @Sql nvarchar(max)
set @Sql = "select * from (select * from (select * from (" + @StringData + ") A) B
                                where RowNum between " + cast(@Start as nvarchar(50)) + " and " + cast(@End as nvarchar(50)) + ") D "
if @QueryFilter <>''
begin
    set @Sql = @Sql + @QueryFilter
end
print 'SQL Remain'
print '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
print @Sql
print '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
EXECUTE sp_executesql @Sql
END

0 comments:

Post a Comment

Nam Le © 2014 - Designed by Templateism.com, Distributed By Templatelib