# SQL Database Connector pagination solution (MS SQL)

**URL:** <https://forum.bubble.io/t/sql-database-connector-pagination-solution-ms-sql/234555>\
**Category:** Tips\
**Created:** [November 28, 2022, 9:39pm UTC](https://forum.bubble.io/t/sql-database-connector-pagination-solution-ms-sql/234555 "2022-11-28T21:39:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![augusto.salles](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/augusto.salles/32/259044_2.png) [@augusto.salles](https://forum.bubble.io/u/augusto.salles)\
**Post date:** [November 28, 2022, 9:39pm UTC](https://forum.bubble.io/t/sql-database-connector-pagination-solution-ms-sql/234555/1 "2022-11-28T21:39:32Z")

</div>

Hello there,

I struggled a bit with SQL Connector pagination, to go around the 200 rows limit bubble imposes and I thought of sharing here, since it might help someone else’s project.

The the idea is to add two parameters in the connector “Page” and “PageSize”. This SQL code then defines the page number you want and the size of this page, limited to 200.

All you need to do is to add your query in the /\* YOUR QUERY GOES HERE \*/ space, add the parameter and it should work fine.

```
/* lead_table_cnpj_filter*/
DECLARE @PageNum INT, @Size INT
SET @PageNum = @Page
SET @Size = @PageSize
BEGIN 
	WITH load_table as (
	    	ROW_NUMBER() OVER(ORDER BY l.sectorId ASC) as row_num,
	    	/* YOUR QUERY GOES HERE */
    	)
    	SELECT * FROM load_table
    	WHERE row_num > IIF(@PageNum<=0, 1, (@PageNum-1)*IIF(@Size>200,200,@Size))
    		AND row_num <= IIF(@PageNum<=0, IIF(@Size>200,200,@Size), @PageNum*IIF(@Size>200,200,@Size))
    END

```

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/9/e/9e075964b825bf1dd9315242c235f67df3a735e6.png)

---

<div class="post-metadata">

**Author:** ![christo1](https://avatars.discourse-cdn.com/v4/letter/c/9f8e36/32.png) [@christo1](https://forum.bubble.io/u/christo1)\
**Post date:** [November 28, 2022, 9:56pm UTC](https://forum.bubble.io/t/sql-database-connector-pagination-solution-ms-sql/234555/2 "2022-11-28T21:56:28Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![ben13](https://avatars.discourse-cdn.com/v4/letter/b/53a042/32.png) [@ben13](https://forum.bubble.io/u/ben13)\
**Post date:** [November 28, 2022, 10:23pm UTC](https://forum.bubble.io/t/sql-database-connector-pagination-solution-ms-sql/234555/3 "2022-11-28T22:23:46Z")

</div>

There is also this solution (which is similar to yours): [[Solved] SQL Database Request with FETCH - #2 by ben13](http://forum.bubble.io/t/solved-sql-database-request-with-fetch/233236/2)

And if you really don’t want to deal with the limit you can you can try our paid plugin: [SQL Database Connector Pro Plugin | Bubble](https://bubble.io/plugin/sql-database-connector-pro-1659728184544x363497584834641900)
