Tuesday, 26 January 2016

How to a function call in stored procedure?

CREATE FUNCTION [dbo].[fnGetBookingId](@customerId int)
RETURNS int
AS
BEGIN
    DECLARE @ret int;
    SELECT @ret= Id
  FROM dbo.RoomForCustomer
  where CustomerId=@customerId
     IF (@ret IS NULL)
        SET @ret = 0;
    RETURN @ret;
END;


CREATE proc [dbo].[GetAllCustomer]
As
Begin
select c.Id, c.Name, c.Gender, c.Religion, c.Email, c.Country, c.PhoneNo, c.Address, c.CraetedDate,
c.Status, c.AgentId,c.PassportNo, dbo.fnGetBookingId(c.Id) as BookingId
from dbo.Customer As c Order by BookingId desc                
END



No comments:

Post a Comment