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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Strange Problem in Stored Procedure

Author  Topic 

SHIVPREET2K1
Starting Member

32 Posts

Posted - 2008-06-26 : 08:12:33
Dear Friends

I have created a stored procedure in sql server which is like this

create procedure get_currency_from_symbol
@currency_Name char(25) output,
@currency_Symbol char(5) output

as

begin

select @currency_name=currency_name from currency_master
where Currency_Symbol LIKE @currency_Symbol
end



This procedure is even working with the statement


declare @currency_Name char(25),@currency_Symbol Char(5)

set @Currency_Symbol='Rs.'

Execute Get_Currency_from_Symbol @Currency_Symbol,@Currency_Name output

select @Currency_Symbol,@currency_Name


But the problem is that it giving me null as a result in currency name field. the data corrospond to it in the table is 'Rupee'

Can any one suggest me where is my mistake.

Thanks in advance

Shivpreet2k1

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2008-06-26 : 08:17:52
@currency_symbol is not an output variable as you are feeding this to the SP.
Go to Top of Page

SHIVPREET2K1
Starting Member

32 Posts

Posted - 2008-06-26 : 08:21:57
Thnaks for the reply friend

but then how should i feed this variable in the sp.

Thanks once again

shivpreet2k1
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2008-06-26 : 08:45:47
Are you also sure you want to be using the LIKE construct without using the % (wildcard) operator in the search condition?
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2008-06-26 : 09:35:47
I must be asleep today as didn't even spot that.

SHIVPREET2K1 - Remove the output from the end of the variable on the declaration and change the LIKE for =
Go to Top of Page

SHIVPREET2K1
Starting Member

32 Posts

Posted - 2008-06-26 : 13:34:54
Thanks friend

i have done that but still it shows only null value.

thanks once again.

shivpreet2k1
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-26 : 13:42:37
quote:
Originally posted by SHIVPREET2K1

Thanks friend

i have done that but still it shows only null value.

thanks once again.

shivpreet2k1


Do you have a record in currency_master with Currency_Symbol value 'Rs.'?
Go to Top of Page
   

- Advertisement -