TSQL - How to check a function

Hi Experts,

I have this function:
USE [NOAH2-PSW]
GO
/****** Object:  UserDefinedFunction [dbo].[fncPSWAllIndividualRenew]    Script Date: 5/15/2015 10:27:07 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO




ALTER FUNCTION [dbo].[fncPSWAllIndividualRenew](	
@GroupType nvarchar(50),
@GroupCode nvarchar(50), 
@WorkFileCode nvarchar(50),
@Date1 date,
@Year nvarchar(4)
)
-- =============================================
-- Author:		tjw
-- Create date: 3/14/2014
-- Description:	Returns any membership, SIG or Certification/Accreditation fees due in the given month if the items aren't datestamped. If one of those things is a membership,
--				then the membership address is used for all items.  Added in address information for Excel output.
-- History:		
--				10/21/2014	Added DECEASED/PURGE check --tjw
--				3/12/2015	Added/moved "DoNotRenew" to the WPQC renewal function --tjw
-- =============================================
RETURNS TABLE
AS
RETURN (
SELECT        IOUs.Contact, fncUtlContactName.NameSort, fncUtlContactName.Name AS ContactName, fncUtlKeyEmail.KeyEmailEntry AS Email, 
                         fncUtlKeyPhone.KeyPhoneEntry AS Phone, IOUs.Address, IOUs.MemberExpire, IOUs.CompanyPaid, IOUs.EmployerID, IOUs.Code1, IOUs.Code2, IOUs.Date2, IOUs.GradYear, 
                         IOUs.NewCode2, IOUs.HotKey, IOUs.HotKeyDescription, IOUs.List, fncUtlAddress.AddressID, fncUtlAddress.Contact AS Expr1, 
                         fncUtlAddress.Which, fncUtlAddress.IsKeyAddress, fncUtlAddress.IsInvoiceAddress, fncUtlAddress.Hold, fncUtlAddress.DirectoryAddress, 
                         fncUtlAddress.EmployerAddress, fncUtlAddress.Salutation, fncUtlAddress.Adressee, fncUtlAddress.Position, fncUtlAddress.Company, fncUtlAddress.Department, 
                         fncUtlAddress.Address1, fncUtlAddress.Address2, fncUtlAddress.City, fncUtlAddress.ZipCode, fncUtlAddress.State, fncUtlAddress.StateDesc, fncUtlAddress.County, 
                         fncUtlAddress.Region, fncUtlAddress.Country, fncUtlAddress.CountryCode, fncUtlAddress.CountryDisplay, fncUtlAddress.CITYST, fncUtlAddress.SortLocation
FROM		(			  SELECT        Contact, Address, MemberExpire, CompanyPaid, EmployerID, Code1, Code2, Date2, GradYear, NewCode2, HotKey, HotKeyDescription, List
                          FROM            dbo.fncPSWIndividualMemberRenew(@Date1, @Year)
						 -- WHERE				CompanyPaid = 0
                          UNION
                          SELECT        fncPSWIndividualWPQCRenew.Contact, ISNULL(Mbr.Address, fncPSWIndividualWPQCRenew.Address) AS Expr1, 
                                                   fncPSWIndividualWPQCRenew.MemberExpire, fncPSWIndividualWPQCRenew.CompanyPaid, EmployerID, fncPSWIndividualWPQCRenew.Code1, 
                                                   fncPSWIndividualWPQCRenew.Code2, fncPSWIndividualWPQCRenew.Date2, fncPSWIndividualWPQCRenew.GradYear, 
                                                   fncPSWIndividualWPQCRenew.NewCode2, fncPSWIndividualWPQCRenew.HotKey, 
                                                   fncPSWIndividualWPQCRenew.HotKeyDescription, fncPSWIndividualWPQCRenew.List
                          FROM            dbo.fncPSWIndividualWPQCRenew(@Date1, @Year) AS fncPSWIndividualWPQCRenew LEFT OUTER JOIN (
														SELECT Contact, Address 
														FROM dbo.fncPSWIndividualMemberRenew(@Date1, @Year)
														WHERE CompanyPaid = 0 --Only override address if the PSW member address is the individuals
										) Mbr ON 
                                                   Mbr.Contact = fncPSWIndividualWPQCRenew.Contact
						  --WHERE			/*CompanyPaid = 0 AND */Inactive = 0
                          UNION
                          SELECT        fncPSWLTCRenew.Contact, ISNULL(Mbr.Address, fncPSWLTCRenew.Address) AS Expr1, fncPSWLTCRenew.MemberExpire, 
                                                   fncPSWLTCRenew.CompanyPaid, EmployerID, fncPSWLTCRenew.Code1, fncPSWLTCRenew.Code2, fncPSWLTCRenew.Date2, fncPSWLTCRenew.GradYear, 
                                                   fncPSWLTCRenew.NewCode2, fncPSWLTCRenew.HotKey, fncPSWLTCRenew.HotKeyDescription, 
                                                   fncPSWLTCRenew.List
                          FROM            dbo.fncPSWLTCRenew(@Date1) AS fncPSWLTCRenew LEFT OUTER JOIN (
														SELECT Contact, Address 
														FROM dbo.fncPSWIndividualMemberRenew(@Date1, @Year)
														WHERE CompanyPaid = 0 --Only override address if the PSW member address is the individuals
										) Mbr ON 
                                                   Mbr.Contact = fncPSWLTCRenew.Contact
						  --WHERE			CompanyPaid = 0
				) AS IOUs INNER JOIN
                dbo.fncUtlContactName() AS fncUtlContactName ON fncUtlContactName.Contact = IOUs.Contact INNER JOIN
                dbo.fncUtlAddress() AS fncUtlAddress ON fncUtlAddress.AddressID = IOUs.address LEFT OUTER JOIN
                dbo.fncUtlKeyEmail() AS fncUtlKeyEmail ON fncUtlKeyEmail.Contact = IOUs.Contact LEFT OUTER JOIN
                dbo.fncUtlKeyPhone() AS fncUtlKeyPhone ON fncUtlKeyPhone.Contact = IOUs.Contact LEFT OUTER JOIN
				dbo.fncUtlDateStampCheck(@GroupType, @GroupCode, @WorkFileCode) ON fncUtlDateStampCheck.Contact = IOUs.Contact
WHERE
		fncUtlDateStampCheck.Contact is NULL AND
		fncUtlContactName.ContactStatus NOT IN ('DECEASED','PURGE')

)

Open in new window


I want to see what it does, you know like when you exec a SP, I am knew to this.


Please help and thanks
Amour22015Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
That function returns a table with the result of the select that is written there.
You can also confirm my the comments in the function:
Returns any membership, SIG or Certification/Accreditation fees due in the given month if the items aren't datestamped. If one of those things is a membership,then the membership address is used for all items.  Added in address information for Excel output.
 
And it only return members that still alive [fncUtlContactName.ContactStatus NOT IN ('DECEASED','PURGE')]
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Barry CunneyCommented:
Hi Amour
The function you have posted appears to be a Table Valued Function(TVF)  so you can do a select from it similar to a select from a normal table - but for the TVF you will have to also supply relevant parameters - so something like the following

SELECT * FROM [dbo].[fncPSWAllIndividualRenew]
(      
'A Valid Group Type String',
'A Valid Group Code String',
A Valid Work File Code String,
GETDATE(),
'2014'
)

You will have to research in your underlying database data what are valid values for the parameters - this will be specific to the data you are dealing with
0
Amour22015Author Commented:
Ok, thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.