Reputation: 546
I have this seemingly working query:
USE [Development Westy]
GO
SELECT [ToReadType_60]
FROM [dbo].['SMART Month End'] AS e
INNER JOIN [dbo].['SMART Reads$'] AS p
ON e.ContractNumber LIKE p.[Contract Number]
GO
How would I limit the number of rows returned? I cannot seem to get it to take the LIMIT command.
I am running the above but it is taking a long time as there are millions of rows, so I want to test it using just a small selection.
Thanks,
Upvotes: 0
Views: 760
Reputation: 632
Use the TOP
command and specify the amount of rows you want returned.
USE [Development Westy]
GO
SELECT TOP 100 [ToReadType_60]
FROM [dbo].['SMART Month End'] AS e
INNER JOIN [dbo].['SMART Reads$'] AS p
ON e.ContractNumber LIKE p.[Contract Number]
Upvotes: 1
Reputation: 1269753
You can just use TOP
:
SELECT TOP 100 [ToReadType_60]
FROM [dbo].['SMART Month End'] e INNER JOIN
[dbo].['SMART Reads$'] p
ON e.ContractNumber = p.[Contract Number];
I would also suggest using =
instead of like
. And indexes on the columns used for the join
s can help performance.
Upvotes: 2