Select first row only

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    Select first row only

    Hi i want to select the first row only in my table... i have this:

    [code=sql]
    declare @abc varchar(2000)
    set @abc = (select Sql_Table_Name from temptable10)
    print @abc
    [/code]

    how can i edit it to only retrieve the value from the first row only?

    Thanks
  • azimmer
    Recognized Expert New Member
    • Jul 2007
    • 200

    #2
    Originally posted by jamesd0142
    Hi i want to select the first row only in my table... i have this:

    [code=sql]
    declare @abc varchar(2000)
    set @abc = (select Sql_Table_Name from temptable10)
    print @abc
    [/code]

    how can i edit it to only retrieve the value from the first row only?

    Thanks
    Use the TOP keyword:
    Code:
    declare @abc varchar(2000)
    set @abc = (select [B]TOP 1[/B] Sql_Table_Name from temptable10)
    print @abc

    Comment

    Working...