March 23, 2011 at 12:10 pm
CREATE PROCEDURE TestSproc2
@size int = 20,
@current int ,
@columns varchar(1000) = '*',
@tableName varchar(100),
@condition varchar(1000) = '',
@ascColumn varchar(100) = '',
@bitOrderType bit = 0,
@pkColumn varchar(50) = ''
AS
DECLARE @strTemp varchar(300)
DECLARE @strSql varchar(5000)
DECLARE @strOrderType varchar(1000)
BEGIN
IF @bitOrderType = 1
BEGIN
SET @strOrderType = ' ORDER BY '+@ascColumn+' DESC'
SET @strTemp = '<(SELECT min'
END
ELSE
BEGIN
SET @strOrderType = ' ORDER BY '+@ascColumn+' ASC'
SET @strTemp = '>(SELECT max'
END
IF @current = 1
BEGIN
IF @condition != ''
SET @strSql = 'SELECT TOP '+STR(@size)+' '+@columns+' FROM '+@tableName+
' WHERE '+@condition+@strOrderType
ELSE
SET @strSql = 'SELECT TOP '+STR(@size)+' '+@columns+' FROM '+@tableName+@strOrderType
END
ELSE
BEGIN
IF @condition !=''
SET @strSql = 'SELECT TOP '+STR(@size)+' '+@columns+' FROM '+@tableName+
' WHERE '+@condition+' AND '+@pkColumn+@strTemp+'('+@pkColumn+')'+' FROM (SELECT TOP '+STR((@current-1)*@size)+
' '+@pkColumn+' FROM '+@tableName+ 'where'+@condition+@strOrderType+') AS TabTemp)'+@strOrderType
ELSE
SET @strSql = 'SELECT TOP '+STR(@size)+' '+@columns+' FROM '+@tableName+
' WHERE '+@pkColumn+@strTemp+'('+@pkColumn+')'+' FROM (SELECT TOP '+STR((@current-1)*@size)+' '+@pkColumn+
' FROM '+@tableName+@strOrderType+') AS TabTemp)'+@strOrderType
END
END
EXEC (@strSql)
March 23, 2011 at 1:23 pm
Pretty. But I didn't see a question or a statement in there.
Please use the forum to ask questions only. There are other places to properly post pretty code for others to benefit from.
Jim
Jim Murphy
http://www.sqlwatchmen.com
@SQLMurph
March 27, 2011 at 12:08 am
Vinit,
Did you get an output for the stored proc?
If so can you please explain.
Alicia Rose
March 27, 2011 at 12:12 am
Jim
Can you please help by explaining what is the purpose of the stored proc and what are the possible testcases and test scripts for it.
Thanks,
Alicia Rose
March 27, 2011 at 12:12 am
Jim
Can you please help by explaining what is the purpose of the stored proc and what are the possible test cases and test scripts for it.
Thanks,
Alicia Rose
March 27, 2011 at 12:12 am
Jim
Can you please help by explaining what is the purpose of the stored proc and what are the possible test cases and test scripts for it.
Thanks,
Alicia Rose
March 27, 2011 at 2:27 pm
Alicia Rose (3/27/2011)
JimCan you please help by explaining what is the purpose of the stored proc and what are the possible test cases and test scripts for it.
Thanks,
Why not just ask the original person who wrote it? Also ask them why they didn't document their code.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply