TOP clause takes INT variable - SQL-Server 2005

Tuesday, March 3, 2009 |

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
GO


DECLARE @ReturnRow INT
SET @ReturnRow=5
SELECT TOP (@ReturnRow) * from Purchasing.Vendor
Reference: Ritesh Shah

0 comments: