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 2000 Forums
 SQL Server Development (2000)
 passing calculated parameter

Author  Topic 

heze
Posting Yak Master

192 Posts

Posted - 2006-04-06 : 14:57:14
hi

Im doing:
---
declare @par as integer
then select * from DB.dbo.MyUserdefFunction(@par+1)
---

the error message is:
Server: Msg 170, Level 15, State 1, Line 5
Line 5: Incorrect syntax near '+'.
---

how can I pass a calculated parameter to my function
when I just pass @par there is no problem

thank you

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-04-06 : 15:02:24
set @par = @par+1
select * from DB.dbo.MyUserdefFunction(@par)
--or
declare @par1 integer
set @par1 = @par+1
select * from DB.dbo.MyUserdefFunction(@par1)




Go with the flow & have fun! Else fight the flow
Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"]
Go to Top of Page

heze
Posting Yak Master

192 Posts

Posted - 2006-04-06 : 15:06:57
thanks s1,
the problem though is that I would have to do the same for evey call, in case I wanted to send 5 different pars I would have to declare 5 different parameters statically.Myabe I could use a while cycle and dynamic sql to join the retunred values which by the ways are tables, but that makes things a little bit more cumbersome.

thanks
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-04-06 : 16:45:36
heze,

Why don't u do ur calculation inside each stored procedure?
Or why don't u keep another procedure or function to return the calculated value and use it as a parameter

Srinika
Go to Top of Page

heze
Posting Yak Master

192 Posts

Posted - 2006-04-06 : 17:08:59
Yes Srin, I will do that, then I send 2 parameters as the operandsd of the addition

thanks
Go to Top of Page
   

- Advertisement -