Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
stahorse
Yak Posting Veteran
86 Posts |
Posted - 2012-09-11 : 07:26:49
|
Hi I have this store proc below and it gives me this error when I try to exec it: "Command(s) completed successfully." I am expecting values back, and I get that message insteadPROC@AppId VARCHAR(10)--validate inputdeclare @a varchar(16)select @a = b.NAMEfrom S_OPTY ainner join S_SALES_METHOD bon a.METHOD_ID = b.ROW_IDwhere a.NAME = @AppIdIF @a = 'Top Ups' or @a = 'Top Ups - Retirement'BEGIN SELECT @AppId AS Application_Id , MB.POLICY_ID AS Policy_Id , MH.BFN_CHG_DATE AS Date_Of_Disinvestment FROM PR_MONEY_BFN MB WITH (NOLOCK) LEFT JOIN PR_MONEY_HIST MH WITH (NOLOCK) ON MB.POLICY_ID = MH.POLICY_ID AND MB.BUS_FUNC_CLASS = MH.BUS_FUNC_CLASS AND MB.BUS_FUNC_DATE = MH.BUS_FUNC_DATE AND MB.BUS_FUNC_NUMBER = MH.BUS_FUNC_NUMBER AND MH.BUS_FUNC_STATUS = '80' LEFT JOIN S_OPTY SO WITH (NOLOCK) ON SO.NAME = MB.APPLICATION_NO WHERE SO.NAME = @AppId END--exec prc_TopUpCancellation @AppId = '1-108719398'please help |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-09-11 : 07:30:46
|
I suspect the value of @a turns out to be something other than the two that you are expecting. Insert a print statement before the IF (see below) and see what the value is......DECLARE @a VARCHAR(16)SELECT @a = b.NAMEFROM S_OPTY a INNER JOIN S_SALES_METHOD b ON a.METHOD_ID = b.ROW_IDWHERE a.NAME = @AppIdPRINT @a;IF @a = 'Top Ups' OR @a = 'Top Ups - Retirement'BEGIN...... |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-11 : 11:21:27
|
one thing i noticed is you've declared @a asdeclare @a varchar(16)and using check condition as@a = 'Top Ups - Retirement'here string is over 16 characters long so if you're expecting similar values alter @a to much higher value to hold them all------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|