TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sadhana Khaire
NA
58
10.2k
Call Table Valued Function in Stored Procedure
Feb 3 2018 1:10 AM
Hi,
I have created one table-valued function. And I want to call this function in stored procedure.
How can I achieve this?
I want to select billid and visitid into SP.
Function query is as below:
CREATE FUNCTION funReturnIPDData
(
)
RETURNS TABLE
AS
RETURN
(
-- Add the SELECT statement with parameter references here
with cte_billinfo(bill_id, visit_id, totalbill) as
(
select B.ipdbill_id, B.ipdpatvisit_id, B.ipdbill_grandtotal from Tbl_IPDBillingDetails B, Tbl_IPDPatientVisit V
where B.ipdpatvisit_id=V.ipdpatvisit_id
),
cte_billselect(billid, visitid)
as
(
select max(bill_id) as billid, visit_id from cte_billinfo c, Tbl_IPDPatientVisit V
group by c.visit_id, V.ipdpatvisit_id, c.totalbill
having c.visit_id=V.ipdpatvisit_id
)
select billid,visitid from cte_billselect
)
GO
Reply
Answers (
2
)
Auto ID generated jumping Values 1000 .. please Urgent
any example for cursor in sql work on multiple tables???