Results 1 to 2 of 2

Thread: Help with getting count values into variables

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    I have a stored procedure. I need to get the two select statements into variables. I need to compare both counts and create and error rountine if they do not much. I am enclosing the code, but would also like help on the error handler;

    Please assist thanks

    CREATE procedure dbo.SpLaLaMonitor
    @TestDate smalldatetime= '11/24/00 11:00'

    SELECT COUNT (*)as 'what does text here produce?' from dev1.dbo.vw_look_txn Where vendor_err='x' and created_dt>@TestDate

    SELECT COUNT (*) as 'what does text here produce?' from Merchant_Order mo join Order_Line ol on ol.Order_ID = mo.Order_ID Where La_To_La=1 and mo.Modified_Date>@TestDate


    EXEC dbo.SpLaLaMonitor

    --GO

  2. #2
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    In query analuser thefollowing worked.

    declare @counter int

    set @counter = (select count(*) from query)
    print @counter


    This printed the relevant value. I know trhis doesn't answer all the question but it should move you on a bit.

    Lenin

Posting Permissions

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



Click Here to Expand Forum to Full Width