×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to get data from function?

How to get data from function?

How to get data from function?

(OP)
Hello
I need to get data from this function:

CODE


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER FUNCTION [dbo].[getitemsavailableqtywithdatets]
(@ItemNo VARCHAR(20),
@Location VARCHAR(10),
@Date DATETIME)
RETURNS TABLE
AS
-- Declare the return variable here
RETURN
SELECT *
FROM (SELECT Isnull(Sum(Quantity),0),
@ItemNo AS [Item No_]
FROM dbo.[Main-db$Item Ledger Entry] WITH (NOLOCK)
WHERE [Item No_] = @ItemNo
AND [Entry Type] = 0
UNION ALL
SELECT Isnull(Sum(tse.Quantity),0),
@ItemNo AS [Item No_]
FROM dbo.[Main-db$Trans_ Sales Entry] tse WITH (NOLOCK)
LEFT OUTER JOIN dbo.[Main-db$Trans_ Sales Entry Status] tses WITH (NOLOCK)
ON tses.[Store No_] = tse.[Store No_]
AND tses.[POS Terminal No_] = tse.[POS Terminal No_]
AND tses.[Transaction No_] = tse.[Transaction No_]
AND tses.[Line No_] = tse.[Line No_]
WHERE tse.[Item No_] = @ItemNo
AND (tses.[Item No_] IS NULL
OR tses.Status = 0)) t(salesqty,[Item No_])

RE: How to get data from function?

Two ANSI SQL ways are:
1. Invoke the function from a SELECT
SELECT [dbo].[getitemsavailableqtywithdatets] (params...) FROM ...

or

2. Do an assignment, e.g.
SET ? = [dbo].[getitemsavailableqtywithdatets] ( params...)
 

RE: How to get data from function?

(OP)
I want to get all data from this function with all date not only for one parametr. Is this possibe?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close