Yes, in SQL Server 2005 it’s possible to use a variable in the top
clause.
select top (@top) * from tablename
More Related Contents:
- Get top 1 row of each group
- Insert results of a stored procedure into a temporary table
- Referring to a Column Alias in a WHERE Clause
- Convert Month Number to Month Name Function in SQL
- SET versus SELECT when assigning variables?
- How important is the order of columns in indexes?
- Generate a resultset of incrementing dates in TSQL
- Using the result of an expression (e.g. Function call) in a stored procedure parameter list?
- Getting result of dynamic SQL into a variable for sql-server
- How to get difference between two rows for a column field?
- Better techniques for trimming leading zeros in SQL Server?
- How to print VARCHAR(MAX) using Print Statement?
- What’s the best way to select the minimum value from several columns?
- Concatenate values based on ID
- Drop all the tables, stored procedures, triggers, constraints and all the dependencies in one sql statement
- For Nvarchar(Max) I am only getting 4000 characters in TSQL?
- Splitting delimited values in a SQL column into multiple rows
- varbinary to string on SQL Server
- How do I group on continuous ranges
- “select * from table” vs “select colA, colB, etc. from table” interesting behaviour in SQL Server 2005
- Is it possible to perform multiple updates with a single UPDATE SQL statement?
- Incorrect syntax near the keyword ‘with’…previous statement must be terminated with a semicolon
- SQL Server 2005 ROW_NUMBER() without ORDER BY
- Can an INNER JOIN offer better performance than EXISTS
- How to escape square brackets inside square brackets for field name
- How do you copy a record in a SQL table but swap out the unique id of the new row?
- Cumulative Total in MS Sql server [duplicate]
- Compare dates in T-SQL, ignoring the time part
- Sql Server : How to use an aggregate function like MAX in a WHERE clause
- Memory effective way to read BLOB data in C#/SQL 2005