Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get data from function?

Status
Not open for further replies.

sniper34

Programmer
May 24, 2010
2
GE
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_])
 
Two ANSI SQL ways are:
1. Invoke the function from a SELECT
[tt]SELECT [dbo].[getitemsavailableqtywithdatets] (params...) FROM ...[/tt]

or

2. Do an assignment, e.g.
[tt]SET ? = [dbo].[getitemsavailableqtywithdatets] ( params...)[/tt]
 
I want to get all data from this function with all date not only for one parametr. Is this possibe?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top