Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    21

    Question Unanswered: Assigning var to count(*) function

    Hi folks,

    I'm trying to obtain the output from the count(*) function and assign it to a variable in a SP. However, it seems that the count() function returns VOID.

    Anyway I can obtain the total number of records based on a query?

    Below's a simple example of what I'd like from the count function:

    declare @total_rows int
    select @total = count(cust_no) from cust_tbl where cust_status = "A"

    Thanks!

  2. #2
    Join Date
    Oct 2003
    Posts
    7

    Re: Assigning var to count(*) function

    Originally posted by lokem
    Hi folks,

    I'm trying to obtain the output from the count(*) function and assign it to a variable in a SP. However, it seems that the count() function returns VOID.

    Anyway I can obtain the total number of records based on a query?

    Below's a simple example of what I'd like from the count function:

    declare @total_rows int
    select @total = count(cust_no) from cust_tbl where cust_status = "A"

    Thanks!
    Works like a charm, you might want to use the same variable though. @total_rows != @total :-)

    /oligus

  3. #3
    Join Date
    Jan 2003
    Posts
    21
    Ack... Darn typo :P Found out that there's an error in the SQL statement

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •