January 9, 2007 at 1:34 pm
I am passing a few values to a proc. The parameter is defined as a decimal within the proc. but the value being passed to the proc is a varchar. Is there a way to convert the datatype as it is being passed to the proc?
I tried this and it didn't work:
exec dbo.s_Proc @Param1 = convert(decimal(12,2),@ParamValue)
The only way I can accomplish it so far is to convert it and set it to another variable and use that variable to pass to the proc.
declare @Paramset @ParamValue2 = convert(decimal(12,2),@ParamValue)
exec dbo.s_Proc @Param1= @ParamValue2
Any suggestions? Thanks.
January 9, 2007 at 2:36 pm
- another reason to split presentation and data.
- convert to the correct datatype asap !
- always do some contenct-checking befor converting.
declare @ParamValue2
if ISNUMERIC(@ParamValue)
begin
set @ParamValue2 = convert(decimal(12,2),@ParamValue)
exec dbo.s_Proc @Param1= @ParamValue2
end
else
begin
raiseerror ('something is wrong')
return (-1)
end
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data and code to get the best help
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply