Groups | Blog | Home
all groups > sql server odbc > september 2003 >

sql server odbc : setting rowcount via odbc?


Robert Paquette
9/5/2003 12:27:30 PM
Hi
I'm trying to limit my result set by using SET ROWCOUNT N where N is my
desired number of rows. The program runs against SQLServer 2000. SQLProfiler
shows the following trace but the row count limit is not applied.

declare @P1 int
set @P1=196
exec sp_prepexec @P1 output, NULL, N'SET ROWCOUNT 6'
select @P1

exec sp_unprepare 196

declare @P1 int
set @P1=197
exec sp_prepexec @P1 output, NULL, N'SELECT USR.USER_ID, USR.FIRST_NM,
USR.LAST_NM, USR.TITLE_TX, USR.LOGIN_ID, USR.PASSWORD_TX, USR.USER_TYPE_CD,
USR.EFF_START_DT, USR.EFF_END_DT, USR.PARTITION_GROUP_NM, USR.LOCK_ID FROM
USERS USR ORDER BY USR.LAST_NM ASC, USR.FIRST_NM ASC'
select @P1

For reasons difficult to describe I can not modify to use SELECT TOP syntax.
Is there a way to set the ROWCOUNT on the connection via the ODBC API so
that it will take effect on my statements executed over that connection?

Sue Hoegemeier
9/5/2003 3:55:42 PM
Take a look at SQLSetStmtOption and SQL_MAX_ROWS option.

-Sue

On Fri, 5 Sep 2003 12:27:30 -0400, "Robert Paquette"
[quoted text, click to view]
AddThis Social Bookmark Button