SQL - Comparing the value returned by a Select against a Parameter in a Store Procedure

Hi
IN the Store Procedure below Im trying to compare the value returned by the Select statement against the parameter @SalesRepFullName.  I am always getting a  'NotMatch'   even when the value of the  parameter passed is the same as what the Select should be returning.  Can someone let me know what am I missing?   THanks

ALTER procedure [LFO].[testSP]
@SalesRepFullName varchar(100),          
@ContractNr nvarchar(50),
@StatusFlag varchar(4000) OUT
AS          
       
BEGIN            
BEGIN TRY    
    DECLARE @FullName varchar(100);
    SELECT @FullName = LTRIM(RTRIM([dbo].Account.SalesRepFullName))      
        FROM [dbo].Account
        WHERE [dbo].Account.ContractNr = @ContractNr
      IF @FullName = LTRIM(RTRIM(@SalesRepFullName))              
             select @StatusFlag = 'Match'  
      ELSE           
           select @StatusFlag = 'NotMatch'  
           
END TRY          
BEGIN CATCH            
 select @StatusFlag = ERROR_MESSAGE()      
END CATCH          
END
chicho12Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dsackerContract ERP Admin/ConsultantCommented:
I'm curious whether the ContractNr/SalesRepFullName are both matching. Taking it from trying to match the SalesrepFullName, are you able to return anything if you run this query in the proc?

SELECT LTRIM(RTRIM(Account.SalesRepFullName)),
       Account.ContractNr,
       @ContractNr AS ParmContractNr
FROM   Account
WHERE  LTRIM(RTRIM(Account.SalesRepFullName)) = LTRIM(RTRIM(@SalesRepFullName)

Open in new window

chicho12Author Commented:
yes, it returned values.

i just added this line below in the ELSE section and its updating the expected row.  So its finding the record but some how the comparison of values is never returning true.
I am testing the Stored pROcedure in SQL server management.

Update [dbo].Account set SalesRepFullName =LTRIM(RTRIM(@SalesRepFullName)) ,UpdatedOn = getdate() where ContractNr = @ContractNr
dsackerContract ERP Admin/ConsultantCommented:
Did the contract numbers match?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chicho12Author Commented:
You were right the contract had a character a the end that didnt see before.  THanks for the help!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.