MySQL Forums
Forum List  »  Microsoft SQL Server

How to convert function that returns TABLE?
Posted by: rdc02271
Date: March 06, 2007 09:45AM

Hello!
How can I convert a function that returns a TABLE type and IS USED in queries, like, SELECT * FROM Item INNER JOIN myFunction(SomeParameter) ON Item.ItemID=myFunction.ItemID

Here's an example:
CREATE FUNCTION [DPVIEW71_0](@TransDocument nvarchar(255),@TransSerial nvarchar(255)) RETURNS TABLE AS Return (SELECT [TransDocNumber], [CreateDate], [DeferredPaymentDate], [PartyID], [PartyName], [TotalNetAmount], [TotalTaxAmount], [TotalTransactionAmount], [CurrencyID], [ContractReferenceNumber] FROM [BuyTransaction] WHERE [BuyTransaction].[TransDocument]=@TransDocument AND [BuyTransaction].[TransSerial]=@TransSerial)

Some of you will ask: Why are you using this?
Answer: Because it hides some implementations details; I may have a sub select working with some of the parameters and I wouldn't be able to just do

SELECT * FROM Item INNER JOIN myFunction(SomeParameter) ON Item.ItemID=myFunction.ItemID


Thanks!
Jorge C.

Options: ReplyQuote


Subject
Written By
Posted
How to convert function that returns TABLE?
March 06, 2007 09:45AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.