PrismaP
Prisma10mo ago
2 replies
Matheus Cardoso

How does Prisma ORM build select Top in SQL Server?

My problem, can reply this query
SELECT TOP 1000 * FROM [User]
ORDER BY [id] ASC
OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;

I have a question about how Prisma builds queries with TOP.

In the code below, which of the SQL statements will Prisma execute in the SQL Server database?

const users = await prisma.user.findMany({
take: 10,
});

Option 1
SELECT TOP 10 * FROM [User];

Option 2
SELECT * FROM [User]
ORDER BY [id] ASC
OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;
Was this page helpful?