selecting count(*) from a table into an int variable

  • ive been trying this a number of ways;

    Declare

    @numRows int

    select

    @numrows = select count(*) from customer

    ======================================

    Declare @numRows int

    set @numrows = select count(*) from customer

    ======================================

     

    Declare @numRows int

    select @numrows = select rowcount from customer

    ======================================

     

    none will work. how can this be accomplished??

     

  • Almost there, you just need a pair of parenthesis

    Declare @numRows int

    select @numrows = (select count(*) from customer)

    /Kenneth

  • so near yet so far. thank you.

  • Also....

    Declare @numRows int

    select @numrows =count(*) from customer

    ------------
    When you 've got a hammer, everything starts to look like a nail...

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply