TOP clause takes INT variable – SQL-Server 2005

 TOP clause takes INT variable – SQL-Server 2005

This is TIPS about new feature of SQL-Server 2005. In SQL-Server 2005 you can use variable in TOP clause which was not possible in any of the older version of Microsoft SQL Server.

You can supply any integer value beside TOP clause in Microsoft SQL-Server 2005 and in 2008. BTW, you can now use TOP clause in INSERT, UPDATE and DELETE also.

USE AdventureWorks




SET @ReturnRow=5

SELECT TOP (@ReturnRow) * from Purchasing.Vendor

Reference: Ritesh Shah

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: