January 13, 2013 at 10:02 am
Hello comunity
I have create this function to return total pairs:
CREATE FUNCTION [dbo].[fnQtRefCor]
(@bostamp varchar(25), @ref varchar(20), @cor varchar(50))
RETURNS int
AS
BEGIN
DECLARE @retval int
SELECT @retval = SUM(qtt) FROM bi
WHERE @bostamp = bostamp AND @ref = ref AND @cor = cor
and bi.ref <> ''
SET @retval = ISNULL(@retval, 0)
RETURN @retval
END
If i run this query:
SELECT SUM(qtt) FROM bi
WHERE bostamp = 'jm13010767476,323000001' AND ref = '2120910'
and (bi.ref <> '')
group by bi.bostamp,ref,cor
I obtain the correct value of : 24
if i run this select to test the result :
select [dbo].[fnQtRefCor] from bi where bi.bostamp = 'jm13010767476,323000001 '
This error appear :
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "dbo.fnQtRefCor" could not be bound.
I can run this SELECT without error ?
Many thanks,
Luis Santos
January 13, 2013 at 10:05 am
Sorry, i forget to mencioned that the compatibility level is :
SQL SERVER 2000 (80)
Maybe the problem is here ??
Thanks
January 13, 2013 at 10:28 am
luissantos (1/13/2013)
Hello comunityI have create this function to return total pairs:
CREATE FUNCTION [dbo].[fnQtRefCor]
(@bostamp varchar(25), @ref varchar(20), @cor varchar(50))
RETURNS int
AS
BEGIN
DECLARE @retval int
SELECT @retval = SUM(qtt) FROM bi
WHERE @bostamp = bostamp AND @ref = ref AND @cor = cor
and bi.ref <> ''
SET @retval = ISNULL(@retval, 0)
RETURN @retval
END
If i run this query:
SELECT SUM(qtt) FROM bi
WHERE bostamp = 'jm13010767476,323000001' AND ref = '2120910'
and (bi.ref <> '')
group by bi.bostamp,ref,cor
I obtain the correct value of : 24
if i run this select to test the result :
select [dbo].[fnQtRefCor] from bi where bi.bostamp = 'jm13010767476,323000001 '
This error appear :
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "dbo.fnQtRefCor" could not be bound.
I can run this SELECT without error ?
Many thanks,
Luis Santos
One thing I see is that you aren't passing in any parameters to the function.
Try the following with the proper values for the parameters.
select [dbo].[fnQtRefCor](@bostamp = ??, @ref = ??, @cor= ??);
January 13, 2013 at 10:35 am
Hello Lynn Pettis
Yes, you are right i forget my parameters (bostamp,ref,cor)
Thanks for your reply
Luis Santos
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply