sql - Variable as top value -


original question:

declare @num int set @num = 5  select top @num col1, col2 table1 

the above not work. not @num being used way. needs done can have variable value next top command?

it gives error:

incorrect syntax near '@num'

select top (@num) table 

sql server 2005 onwards, supported parameterize top.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -