Thursday, March 8, 2012

Create new table with fields from 4 other tables

I want to put fields from four tables into one table. I created a new table, but how do i get the same fields from the other tables to this table along with primary and foreign keys.

Table Fields

Tbl_Date_Dimension --> [Date_Dimension_Year], Date_Dimension_Period], [Date_Dimension_Fiscal_Week]

Tbl_Report_Level --> Report_Level_Id

Tbl_Customer --> Customer_Code

[Sales Fact] --> [Gross Turnover] , Quantity, Consolidated_Sales_Tables_Id

The new table is called Tbl_Sales_Growth

Here's the information on the new table:
[Date_Dimension_Year] [int] NOT NULL,

[Date_Dimension_Period] [int] NOT NULL,

[Date_Dimension_Fiscal_Week] [int] NULL,

[Report_Level_Id] [int] NOT NULL,

[Customer_code] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[Consolidated_Sales_Tables_Id] [tinyint] NOT NULL,

[Quantity] [decimal](18, 0) NOT NULL,

[Gross turnover] [decimal](18, 0) NOT NULL

) ON [PRIMARY]

Quote:

Originally Posted by tenchyz

I want to put fields from four tables into one table. I created a new table, but how do i get the same fields from the other tables to this table along with primary and foreign keys.

Table Fields

Tbl_Date_Dimension --> [Date_Dimension_Year], Date_Dimension_Period], [Date_Dimension_Fiscal_Week]

Tbl_Report_Level --> Report_Level_Id

Tbl_Customer --> Customer_Code

[Sales Fact] --> [Gross Turnover] , Quantity, Consolidated_Sales_Tables_Id

The new table is called Tbl_Sales_Growth

Here's the information on the new table:
[Date_Dimension_Year] [int] NOT NULL,

[Date_Dimension_Period] [int] NOT NULL,

[Date_Dimension_Fiscal_Week] [int] NULL,

[Report_Level_Id] [int] NOT NULL,

[Customer_code] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[Consolidated_Sales_Tables_Id] [tinyint] NOT NULL,

[Quantity] [decimal](18, 0) NOT NULL,

[Gross turnover] [decimal](18, 0) NOT NULL

) ON [PRIMARY]


i'm no expert but i guess all you have to do is create a procedure for this|||

Quote:

Originally Posted by tenchyz

I want to put fields from four tables into one table. I created a new table, but how do i get the same fields from the other tables to this table along with primary and foreign keys.

Table Fields

Tbl_Date_Dimension --> [Date_Dimension_Year], Date_Dimension_Period], [Date_Dimension_Fiscal_Week]

Tbl_Report_Level --> Report_Level_Id

Tbl_Customer --> Customer_Code

[Sales Fact] --> [Gross Turnover] , Quantity, Consolidated_Sales_Tables_Id

The new table is called Tbl_Sales_Growth

Here's the information on the new table:
[Date_Dimension_Year] [int] NOT NULL,

[Date_Dimension_Period] [int] NOT NULL,

[Date_Dimension_Fiscal_Week] [int] NULL,

[Report_Level_Id] [int] NOT NULL,

[Customer_code] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[Consolidated_Sales_Tables_Id] [tinyint] NOT NULL,

[Quantity] [decimal](18, 0) NOT NULL,

[Gross turnover] [decimal](18, 0) NOT NULL

) ON [PRIMARY]


how are these tables related? do you need a physical table or maybe you just need a view

No comments:

Post a Comment