how to call a function in storedprocedure using Sqlserver 2008?

Posted by Hariinakoti under Sql Server on 9/12/2012 | Points: 10 | Views : 5768 | Status : [Member] | Replies : 10
Hi Friends,
how to call a function in storedprocedure using Sqlserver 2008?

Thanks & Regards
Hari



Responses

Posted by: Gopesh9 on: 9/12/2012 [Member] Starter | Points: 25

Up
0
Down
Hey,

Just use like this

set variableName = yourFunctionName(variableName which you want to pass) 


Hope this helps...

G. S.
.Net Developer

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/12/2012 [Member] Starter | Points: 25

Up
0
Down
@Gopesh
Can you explain briefly if possible?

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 9/12/2012 [Member] Starter | Points: 25

Up
0
Down
Yeah,

See, you have to first declare a variable suppose @name, now suppose you have a function called func which takes one argument named @i, having some value.

So, you just write
set @name = func(@i)


Hope this helps...

G. S.
.Net Developer

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/12/2012 [Member] Starter | Points: 25

Up
0
Down
ok,Thanq Gopesh.
i'll try it.

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 9/12/2012 [Member] Starter | Points: 25

Up
0
Down
Where is your function stored in the database??

G. S.
.Net Developer

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/12/2012 [Member] Starter | Points: 25

Up
0
Down
in functions only

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 9/12/2012 [Member] Starter | Points: 25

Up
0
Down
Then you have to use schema name before that function, if you have any...

G. S.
.Net Developer

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tanujad on: 9/12/2012 [Member] Starter | Points: 25

Up
0
Down
following are few ways to call a function in a stored procedure --

SELECT functionName(parameterValue) 


OR

DECLARE @test VARCHAR(20)

SELECT @test = functionName(parameterValue)


OR

DECLARE @test VARCHAR(20)

SET @test = functionName(parameterValue)


Thanks
Tanuja
(If this content helped you, Please mark it as Answer)

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/12/2012 [Member] Starter | Points: 25

Up
0
Down
Thank you tanuja

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/12/2012 [Member] Starter | Points: 25

Up
0
Down
Its ok Gopesh

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response