J
JD
I created a scalar user-defined function in an adp - like
this:
----------------------------------------
Create Function joeUser.Function1
(
@parm1 varchar(20)
)
Returns varchar(20)
As
Begin
Set @parm1 = @parm1 + 'test'
Return @parm1
End
------------------------------------------
If I click on this function - I get the dialog box asking
for a param -- I enter 'shmo' and it returns 'shmotest' as
epxected. But if I run this udf in a view like this:
Select joeUser.Function1(fld1), fld2 From Table1
--say table1 contains 2 rows
fld1 fld2
cat bird
dog ball
the view returns instead of
fld1 fld2 fld1 fl2
cat bird cattest bird
dog ball dogtest ball
But if I change the udf Set @parm1 = @parm1 + 'test'
to Set @parm1 = 'test' + @parm1 now the view returns
fld1 fld2
testcat bird
testdog ball
This udf resides in the adp. If I run the same udf in Sql
Server (2000) -udf owned by dbo instead of joeUser - on
the table owned by joeUser, I get the same results as the
adp view. But if I run dbo.Function1 on a dbo owned
table, then I get cattest, dogtest, the correct results.
Is there a difference between creating a udf in the adp or
creating the same udf in Sql Server? Is there a way to
compensate for this difference?
Thanks,
JD
this:
----------------------------------------
Create Function joeUser.Function1
(
@parm1 varchar(20)
)
Returns varchar(20)
As
Begin
Set @parm1 = @parm1 + 'test'
Return @parm1
End
------------------------------------------
If I click on this function - I get the dialog box asking
for a param -- I enter 'shmo' and it returns 'shmotest' as
epxected. But if I run this udf in a view like this:
Select joeUser.Function1(fld1), fld2 From Table1
--say table1 contains 2 rows
fld1 fld2
cat bird
dog ball
the view returns instead of
fld1 fld2 fld1 fl2
cat bird cattest bird
dog ball dogtest ball
But if I change the udf Set @parm1 = @parm1 + 'test'
to Set @parm1 = 'test' + @parm1 now the view returns
fld1 fld2
testcat bird
testdog ball
This udf resides in the adp. If I run the same udf in Sql
Server (2000) -udf owned by dbo instead of joeUser - on
the table owned by joeUser, I get the same results as the
adp view. But if I run dbo.Function1 on a dbo owned
table, then I get cattest, dogtest, the correct results.
Is there a difference between creating a udf in the adp or
creating the same udf in Sql Server? Is there a way to
compensate for this difference?
Thanks,
JD