Declare @temp_account table
(
 account_number varchar(30) null,
 acctactbeginning_bal int
)

Declare @temp_project table
(
 project_number varchar(30) null,
 pro_beginning_bal int
)

INSERT INTO @temp_account (account_number, beginning_bal)
SELECT GL7Accounts.AccountNumber "Account Number",
dbo.GL7GetAccountBalance(1, GL7ACCOUNTS.ACCOUNTNUMBER,  '2012/1/1', '',1,-1,0,0,0,0,0,0,0,-1,1,0) "Beginning balance_1"
FROM dbo.GL7Accounts

                  
INSERT INTO @temp_project(project_number, beginning_bal)
SELECT GL7Projects.ProjectID "Project Number",
dbo.GL7GetProjectBalance(1, 0, '2012/1/1', GL7PROJECTS.GL7PROJECTSID, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, -1)"Beginning Balance"
FROM dbo.GL7Projects

SELECT TA.ACCOUNT_NUMBER, TA.beginning_bal, PJ.project_number, PJ.beginning_bal

FROM ((GL7PROJECTS
INNER JOIN (GL7ACCOUNTS INNER JOIN GL7AccountToProject ON GL7ACCOUNTS.GL7ACCOUNTSID = GL7AccountToProject.GL7ACCOUNTSID) ON GL7PROJECTS.GL7PROJECTSID = GL7AccountToProject.GL7PROJECTSID)
INNER JOIN @temp_project PJ ON GL7PROJECTS.PROJECTID = PJ.project_number)
INNER JOIN @temp_Account TA ON GL7ACCOUNTS.ACCOUNTNUMBER = TA.account_number

GO

Disclaimer: Blackbaud provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Structured Query Language and the tools used to create and modify SQL statements and Crystal Reports. Blackbaud Customer Support may help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality.