SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


many to many join and union all


many to many join and union all

Author
Message
wtolbert
wtolbert
SSC Rookie
SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)

Group: General Forum Members
Points: 36 Visits: 51
I'm having a hard time with this query this afternoon. I have 3 tables cash, revenue, expense. I need to join them together keeping all rows along with begin_balance, end_balance, and revenue. There are several rows per building all having different totals.

Sample data:
Revenue_table
building_code - 125, 125, 125
function_code – null, null, null
fund_code - 001, 001, 001
receipt_code – 14, 18, 31
object_code - null, null, null
revenue - 24463.24, 0, 825625.16
begin_balance - null, null, null
end_balance - null, null, null
year - 2007-12


Expense_table
building_code - 125, 125, 125
fund_code - 001, 001, 001
function_code – 11, 11, 11
receipt_code - null, null, null
object_code – 41, 41, 42
revenue - 24463.24, 0, 825625.16
begin_balance - null, null, null
end_balance - null, null, null
year - 2007-12

Cash_table
building_code - 125, 125, 125
function_code - null, null, null
fund_code - 001, 006, 007
receipt_code - null, null, null
object_code - 41, 41, 42
revenue - null, null, null
begin_balance - 206891.77, 0, 424.65
end_balance - 764207, -13522.95, 494.65
year - 2007-12

What is needed is to join on building_code and foreign keys to merge data together than possibly union the tables together creating one table in which all the data exists. I was uncertain as to how to join on tables with many to many relationships without producing unnecessary matches.
J Livingston SQL
J Livingston SQL
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11700 Visits: 37453
Hi

seems you are new around here...so a big welcome ...hopefully you will find this site a friendly and helpful resource.

first off...you have posted in SQL 7 , 2000 forum...is this the SQL version that you are using?
only asking cos it will make a difference to the answers provided......

are you familiar with how to provide "create table" statements and how to provide data to populate said tables ?.....this will make it far more likely that you will receive a tried and tested answer...if not please post back and we can give you some pointers.

________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day

wtolbert
wtolbert
SSC Rookie
SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)

Group: General Forum Members
Points: 36 Visits: 51
J I am new. Thank you for the welcome. Any pointers will be helpful. SQL Server 7, 2000 is not what I was looking for.
J Livingston SQL
J Livingston SQL
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11700 Visits: 37453
wtolbert (1/9/2013)
J I am new. Thank you for the welcome. Any pointers will be helpful. SQL Server 7, 2000 is not what I was looking for.


ok...what version of MS SQL are you working with?

assuming you already have a SQL table with data called "Revenue_table " ?...correct?

do you know how to script this out (with data) to enable the forum to easily use your output (eg cut and paste into their version of SSMS and thereby replicate what you can see)...??

regards

________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day

wtolbert
wtolbert
SSC Rookie
SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)

Group: General Forum Members
Points: 36 Visits: 51
I'm using SQL Server 2008 R2 and the tables are not very large but I can condense them to a small sample size and produce the schema and data.
J Livingston SQL
J Livingston SQL
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11700 Visits: 37453
great...look fwd to seeing the scripts

________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day

wtolbert
wtolbert
SSC Rookie
SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)

Group: General Forum Members
Points: 36 Visits: 51
I have the schema and data. Not sure where I should attach it?
Evil Kraig F
Evil Kraig F
SSCoach
SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)

Group: General Forum Members
Points: 19665 Visits: 7660
wtolbert (1/9/2013)
I have the schema and data. Not sure where I should attach it?


Instead of attaching it, it's best if you simply put it into the post and wrap it with the code="sql" tags you'll see in the ifCode shortcuts you'll see on the left. Many of us here are a bit fearful of downloading anything from the internet simply because a lot of us are on our work machines.


- Craig Farrell

Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

For better assistance in answering your questions | Forum Netiquette
For index/tuning help, follow these directions. |Tally Tables

Twitter: @AnyWayDBA
wtolbert
wtolbert
SSC Rookie
SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)

Group: General Forum Members
Points: 36 Visits: 51
Thanks Craig.

CREATE TABLE [dbo].[RAW_Financial_revenue_test](
[year_time] [varchar](100) NULL,
[district_code] [varchar](150) NULL,
[district_name] [varchar](150) NULL,
[FUND_CODE] [varchar](150) NULL,
[fund_description] [varchar](150) NULL,
[fund_type] [varchar](150) NULL,
[source_data] [varchar](250) NULL,
[source_state] [varchar](100) NULL,
[function_code] [varchar](150) NULL,
[function_description] [varchar](150) NULL,
[source_code] [varchar](100) NULL,
[source_description] [varchar](150) NULL,
[receipt_code] [varchar](100) NULL,
[receipt_description] [varchar](150) NULL,
[object_code] [varchar](100) NULL,
[object_description] [varchar](150) NULL,
[begin_balance] [varchar](100) NULL,
[end_balance] [varchar](100) NULL,
[actual] [varchar](100) NULL,
[budget] [varchar](100) NULL,
[report_type] [varchar](5) NULL,
[account_type_code] [varchar](5) NULL,
[account_type_desc] [varchar](50) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', NULL, NULL, NULL, NULL, NULL, NULL, N'1410', N'Interest on Investments *', NULL, NULL, NULL, NULL, N'24463.24', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', NULL, NULL, NULL, NULL, NULL, NULL, N'1890', N'Other Miscellaneous Receipts *', NULL, NULL, NULL, NULL, N'0', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', NULL, NULL, NULL, NULL, NULL, NULL, N'3110', N'School Foundation Basic Allowance *', NULL, NULL, NULL, NULL, N'825625.16', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', NULL, NULL, NULL, NULL, NULL, NULL, N'3110', N'School Foundation Basic Allowance *', NULL, NULL, NULL, NULL, N'9745.89', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', NULL, NULL, NULL, NULL, NULL, NULL, N'3110', N'School Foundation Basic Allowance *', NULL, NULL, NULL, NULL, N'74245.4', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', NULL, NULL, NULL, NULL, NULL, NULL, N'3110', N'School Foundation Basic Allowance *', NULL, NULL, NULL, NULL, N'41152.86', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'006', N'Food Services ', N'Special Revenue Fund/Permanent fund/Private Purpose fund', NULL, NULL, NULL, NULL, NULL, NULL, N'1512', N'Sales of Type A Lunches to Students *', NULL, NULL, NULL, NULL, N'39', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'006', N'Food Services ', N'Special Revenue Fund/Permanent fund/Private Purpose fund', NULL, NULL, NULL, NULL, NULL, NULL, N'4210', N'Restricted Grants-in-aid Received Directly from Federal Government *', NULL, NULL, NULL, NULL, N'3724.8', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', NULL, NULL, NULL, NULL, NULL, NULL, N'1820', N'Contributions and Donations from Private Sources *', NULL, NULL, NULL, NULL, N'270', NULL, N'A', N'R', N'revenue')
INSERT [dbo].[RAW_Financial_revenue_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', NULL, NULL, NULL, NULL, NULL, NULL, N'1820', N'Contributions and Donations from Private Sources *', NULL, NULL, NULL, NULL, N'2500', NULL, N'A', N'R', N'revenue')
/****** Object: Table [dbo].[RAW_Financial_expense_test] Script Date: 01/09/2013 18:04:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[RAW_Financial_expense_test](
[year_time] [varchar](100) NULL,
[district_code] [varchar](150) NULL,
[district_name] [varchar](150) NULL,
[FUND_CODE] [varchar](150) NULL,
[fund_description] [varchar](150) NULL,
[fund_type] [varchar](150) NULL,
[source_data] [varchar](250) NULL,
[source_state] [varchar](100) NULL,
[function_code] [varchar](150) NULL,
[function_description] [varchar](150) NULL,
[source_code] [varchar](100) NULL,
[source_description] [varchar](150) NULL,
[receipt_code] [varchar](100) NULL,
[receipt_description] [varchar](150) NULL,
[object_code] [varchar](100) NULL,
[object_description] [varchar](150) NULL,
[begin_balance] [varchar](100) NULL,
[end_balance] [varchar](100) NULL,
[actual] [varchar](100) NULL,
[budget] [varchar](100) NULL,
[report_type] [varchar](5) NULL,
[account_type_code] [varchar](5) NULL,
[account_type_desc] [varchar](50) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'412', N'Instructional Improvement Services:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'419', N'Other Professional and Technical Services:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'425', N'Early Childhood Education', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'432', N'Management Information System', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'433', N'Non-Certificated Travel Reimbursement:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'441', N'Telephone Service:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'443', N'Summer School Remediation', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'449', N'Other Communication Services:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'461', N'Printing and Binding:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
INSERT [dbo].[RAW_Financial_expense_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Expenditure_Folders\FY07_exp.txt', N'OH', N'1140', N'Alternative School', NULL, NULL, NULL, NULL, N'469', N'Other Craft and Trade Services:', NULL, NULL, NULL, NULL, NULL, N'E', N'expense')
/****** Object: Table [dbo].[RAW_Financial_balancesheet_test] Script Date: 01/09/2013 18:04:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[RAW_Financial_balancesheet_test](
[year_time] [varchar](100) NULL,
[district_code] [varchar](150) NULL,
[district_name] [varchar](150) NULL,
[FUND_CODE] [varchar](150) NULL,
[fund_description] [varchar](150) NULL,
[fund_type] [varchar](150) NULL,
[source_data] [varchar](250) NULL,
[source_state] [varchar](100) NULL,
[function_code] [varchar](150) NULL,
[function_description] [varchar](150) NULL,
[source_code] [varchar](100) NULL,
[source_description] [varchar](150) NULL,
[receipt_code] [varchar](100) NULL,
[receipt_description] [varchar](150) NULL,
[object_code] [varchar](100) NULL,
[object_description] [varchar](150) NULL,
[begin_balance] [varchar](100) NULL,
[end_balance] [varchar](100) NULL,
[actual] [varchar](100) NULL,
[budget] [varchar](100) NULL,
[report_type] [varchar](5) NULL,
[account_type_code] [varchar](5) NULL,
[account_type_desc] [varchar](50) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'001', N'General', N'Debt Service Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'206891.77', N'764207', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'006', N'Food Services ', N'Special Revenue Fund/Permanent fund/Private Purpose fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'0', N'-13522.95', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'424.65', N'494.65', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'1354.86', N'1047.82', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'0', N'2500', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'0', N'485.88', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'007', N'Special Trust ', N'Special Revenue Fund/Private Purpose fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'0', N'17423.76', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'018', N'Public School Support', N'Special Revenue Fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'30', N'30', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'019', N'Other Grants', N'Enterprise fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'38737.6', N'38737.6', NULL, NULL, N'A', NULL, NULL)
INSERT [dbo].[RAW_Financial_balancesheet_test] ([year_time], [district_code], [district_name], [FUND_CODE], [fund_description], [fund_type], [source_data], [source_state], [function_code], [function_description], [source_code], [source_description], [receipt_code], [receipt_description], [object_code], [object_description], [begin_balance], [end_balance], [actual], [budget], [report_type], [account_type_code], [account_type_desc]) VALUES (N'2007', N'000125', N'Polly Fox Academy Community School', N'019', N'Other Grants', N'Enterprise fund', N'\\f5adev01\transfer\OHK12\AFR and Budget\Cash_Records\FY07_Cash_Record.txt', N'OH', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N'1279.5', N'585.1', NULL, NULL, N'A', NULL, NULL)


Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (206K reputation)SSC Guru (206K reputation)SSC Guru (206K reputation)SSC Guru (206K reputation)SSC Guru (206K reputation)SSC Guru (206K reputation)SSC Guru (206K reputation)SSC Guru (206K reputation)

Group: General Forum Members
Points: 206027 Visits: 41952
What's the PK of each of those tables?

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search