GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Database  >  Stored Procedures
Go To First  |  Previous Question  |  Next Question 
 Stored Procedures  |  Question 5 of 12    Print  
How can I call function in a stored procedure in SQL Server?

  
Total Answers and Comments: 3 Last Update: May 23, 2008     Asked by: Sridhar Rao 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
October 25, 2006 14:40:57   #1  
Roopesh Nanaware        

RE: How can I call function in a stored procedure in S...

CREATE PROCEDURE [usp_select_Act_Actual_Customer]
  (@BranchID    [int],
  @CompanyID    [tinyint])
--WITH ENCRYPTION
AS  
 BEGIN 
  SET NOCOUNT ON
  
  DECLARE @Nulldate [smalldatetime]
  SET @Nulldate  = 0
  
  DECLARE @Serverdate  [smalldatetime]
  SET @Serverdate  = GETDATE()

  SELECT s.[BranchID], s.[CompanyID], s.[FinancialyearID],
  s.[Saledate], s.[Invoiceno], s.[Goodscategoryname],
  s.[Bankname], s.[Customercode], s.[Saletype],
  s.[Customername], s.[Duedays],   
  s.[Duedate], s.[Countryname], s.[Totalquantity],
  s.[Netvalue], s.[NetvalueInLocal],
  s.[Netreceiptamount], s.[Exchangeratetolocal]
  FROM [dbo].[fn_Actual_Tsale](0, @BranchID, @CompanyID) s 
  WHERE s.[Receivablefromagent]  <> 1

  ORDER BY s.[Customername], s.[Saledate]
  RETURN(@@ERROR)
 END 

Ans: This is Procedure And "here we Taking record from (fn_Actual_Tsale) function"


 
Is this answer useful? Yes | No
March 10, 2008 04:23:02   #2  
sampra Member Since: February 2008   Contribution: 279    

RE: How can I call function in a stored procedure in SQL Server?
pls explain wd simple example  
 
Is this answer useful? Yes | No
May 23, 2008 07:18:26   #3  
praveengowda Member Since: August 2007   Contribution: 3    

RE: How can I call function in a stored procedure in SQL Server?

A function can be called in a select statement as well as in a stroed proc. As function call would return a value we need to store return value in a variable.

Ex:
Assume we have a fuction .. FN_TEST(Date IN VARCHAR2, ID OUR VARCHAR2) RETURN VARCHAR2.
within stored proc declare a variable to store ID.

ID_VAL VARCHAR2(10) :=  NULL;

ID_VAL :=  FN_TEST('1-may-2008', ID_VAL);

hope this helps


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape