• Hi

    it works 🙂 ... BUT it doesn't return anything. I run it and it says "no recordset returned" what am I missing??

    thanks, Lynda

    quote:


    A couple of problems I can see immediately:

    The code:

     
    
    IF EXISTS(SELECT CustID FROM TblCustomers
    WHERE EmailAddress = @x_Email)
    Set @CustID = CustID
    BEGIN

    ...assume the previous SELECT returns custID, but it doesn't, it simply checks existence.

    Also, the stuff from BEGIN onwards will always be executed, because the SET statement is the only one dependent on the IF.

    An alternative is:

     
    
    SELECT @CustID = CustID FROM TblCustomers
    WHERE EmailAddress = @x_Email
    IF @@ROWCOUNT > 0 -- Yes it exists and @CustID now contains the CustID
    BEGIN
    ...
    END

    Cheers,

    - Mark