how to select first N rows from a table in T-SQL?

前端 未结 7 883
耶瑟儿~
耶瑟儿~ 2020-12-10 10:54

Is there any way to select, for example, first 10 rows of a table in T-SQL (working MSSQL)?
I think I saw something in Oracle defined as rownum meta variable, used in a

相关标签:
7条回答
  • 2020-12-10 11:42

    Try this.

    declare @topval int
    
    set @topval = 5 (customized value)
    
    SELECT TOP(@topval) * from your_database
    
    0 讨论(0)
提交回复
热议问题