Ramon Quintana

Ramon Quintana

  • NA
  • 404
  • 65.9k

Can I to create a Relational-Data-Model from a Select Query?

Jun 26 2019 2:50 PM
Hi,
 
I need to create a Data Model from this query for example:
 
SELECT dbo.Cuentas_Maestro.Numero_cuenta AS Cuentas_Maestro_Numero_cuenta, dbo.Cuentas_Maestro.Profit_Center AS Cuentas_Maestro_Profit_Center, dbo.Cuentas_Maestro.Trading_Partner,
dbo.Cuentas_Maestro.Partner_Profit_Ctr, dbo.Cuentas_Maestro.Trans_Type AS Cuentas_MaestroTransType, dbo.Cuentas_Maestro.profit_center_local_currency, dbo.Cuentas_Maestro.Curr_key AS Cuentas_Maestro_Curr_key,
dbo.Cuentas_Maestro.Functional_Area, dbo.Cuentas_Maestro.Controlling_Area AS Cuentas_Maestro_Controlling_Area, dbo.Cuentas_Maestro.Fiscal_Year, dbo.Cuentas_Maestro.Debit_Credit_Ind,
dbo.Cuentas_Maestro.Origin_Object_num, dbo.Cuentas_Maestro.Elimination_PrCtr, dbo.Cuentas_Maestro.[Transaction], dbo.Cuentas_Maestro.Receiver_object_type, dbo.Cuentas_Maestro.Partner_Func_Area,
dbo.Cuentas_Maestro.Plant, dbo.Cuentas_Maestro.Period, dbo.Transaction_Type.Trans_Type_Desc, dbo.[Accounts_Master-FS00].Descripcion_cuenta,
dbo.Controlling_Area.Controlling_Area_Desc AS Controlling_Area_Controlling_Area_Desc, Area_Funcional_1.Functional_area_Desc, Area_Funcional_1.Tipo_de_costo, dbo.Origin_Object.Origin_Object_description,
dbo.Tasas_de_cambio.Periodo, dbo.Tasas_de_cambio.Average, dbo.Tasas_de_cambio.SPOT, dbo.Cuentas_Maestro.profit_center_local_currency / dbo.Tasas_de_cambio.Average AS Calculo_Tasa,
dbo.Origin_Object_local_2.Origin_Object_description_Receiver, dbo.Depth_Structure.[Short _Text] AS [Short _Text_Elimination], dbo.Depth_Structure.[Cross _Div _Biz] AS [Cross _Div _Biz_Elimination],
dbo.Depth_Structure.[Business _Area] AS [Business _Area_Elimination], dbo.Depth_Structure.[Business _Line] AS [Business _Line_Elimination], dbo.Depth_Structure.[Spiridon _2019] AS [Spiridon _2019_Elimination],
dbo.Depth_Structure.[Business _Subsegment] AS [Business _Subsegment_Elimination], dbo.KS13.Funcionalidad AS Funcionalidad_Elimination, dbo.KS13.[Nombre_ Profit _Center] AS [Nombre_ Profit _Center_Elimination],
Depth_Structure_2.[Short _Text] AS [Short _Text_Origen], Depth_Structure_2.[Cross _Div _Biz] AS [Cross _Div _Biz_Origen], Depth_Structure_2.[Business _Area] AS [Business _Area_Origen],
Depth_Structure_2.[Business _Line] AS [Business _Line_Origen], Depth_Structure_2.[Spiridon _2019] AS [Spiridon _2019_Origen], Depth_Structure_2.[Business _Subsegment] AS [Business _Subsegment_Origen],
KS13_1.[Nombre_ Profit _Center] AS [Nombre_ Profit _Center_Origen], KS13_1.Funcionalidad AS Funcionalidad_Origen, Depth_Structure_1.[Short _Text] AS [Short _Text_Partner],
Depth_Structure_1.[Cross _Div _Biz] AS [Cross _Div _Biz_Partner], Depth_Structure_1.[Business _Area] AS [Business _Area_Partner], Depth_Structure_1.[Business _Line] AS [Business _Line_Partner],
Depth_Structure_1.[Spiridon _2019] AS [Spiridon _2019_Partner], Depth_Structure_1.[Business _Subsegment] AS [Business _Subsegment_Partner], KS13_2.[Nombre_ Profit _Center] AS [Nombre_ Profit _Center_Partner],
KS13_2.Funcionalidad AS Funcionalidad_Partner, dbo.Area_Funcional.Functional_area_Desc AS Functional_area_Desc_Partner, dbo.Area_Funcional.Tipo_de_costo AS Tipo_de_costo_Partner
FROM dbo.KS13 RIGHT OUTER JOIN
dbo.Profit_Center_YH050_3 LEFT OUTER JOIN
dbo.Depth_Structure ON dbo.Profit_Center_YH050_3.[Business _Subsegment__Elimination] = dbo.Depth_Structure.[Spiridon _2019] ON
dbo.KS13.[Controlling _Area] = dbo.Profit_Center_YH050_3.[Controlling _Area_Elimination] AND dbo.KS13.Profit_Center = dbo.Profit_Center_YH050_3.[Profit _Center_Elimination] RIGHT OUTER JOIN
dbo.Area_Funcional RIGHT OUTER JOIN
dbo.Cuentas_Maestro ON dbo.Area_Funcional.Functional_area = dbo.Cuentas_Maestro.Partner_Func_Area ON dbo.Profit_Center_YH050_3.[Controlling _Area_Elimination] = dbo.Cuentas_Maestro.Controlling_Area AND
dbo.Profit_Center_YH050_3.[Profit _Center_Elimination] = dbo.Cuentas_Maestro.Elimination_PrCtr LEFT OUTER JOIN
dbo.KS13 AS KS13_1 RIGHT OUTER JOIN
dbo.Profit_Center_YH050 LEFT OUTER JOIN
dbo.Depth_Structure AS Depth_Structure_2 ON dbo.Profit_Center_YH050.[Business _Subsegment] = Depth_Structure_2.[Spiridon _2019] ON KS13_1.[Controlling _Area] = dbo.Profit_Center_YH050.[Controlling _Area] AND
KS13_1.Profit_Center = dbo.Profit_Center_YH050.[Profit _Center] ON dbo.Cuentas_Maestro.Profit_Center = dbo.Profit_Center_YH050.[Profit _Center] AND
dbo.Cuentas_Maestro.Controlling_Area = dbo.Profit_Center_YH050.[Controlling _Area] LEFT OUTER JOIN
dbo.[Accounts_Master-FS00] ON dbo.Cuentas_Maestro.Numero_cuenta = dbo.[Accounts_Master-FS00].Numero_cuenta LEFT OUTER JOIN
dbo.Origin_Object ON dbo.Cuentas_Maestro.Origin_Object_num = dbo.Origin_Object.Origin_Object_num LEFT OUTER JOIN
dbo.Transaction_Type ON dbo.Cuentas_Maestro.Trans_Type = dbo.Transaction_Type.Trans_Type LEFT OUTER JOIN
dbo.Area_Funcional AS Area_Funcional_1 ON dbo.Cuentas_Maestro.Functional_Area = Area_Funcional_1.Functional_area LEFT OUTER JOIN
dbo.Controlling_Area ON dbo.Cuentas_Maestro.Controlling_Area = dbo.Controlling_Area.Controlling_Area LEFT OUTER JOIN
dbo.Origin_Object_local_2 ON dbo.Cuentas_Maestro.Receiver_object_type = dbo.Origin_Object_local_2.Origin_Object_num_Receiver LEFT OUTER JOIN
dbo.Tasas_de_cambio ON dbo.Cuentas_Maestro.Period = dbo.Tasas_de_cambio.Periodo AND dbo.Cuentas_Maestro.Fiscal_Year = dbo.Tasas_de_cambio.FY AND
dbo.Cuentas_Maestro.Curr_key = dbo.Tasas_de_cambio.Curr_Key LEFT OUTER JOIN
dbo.Profit_Center_YH050_2 LEFT OUTER JOIN
dbo.KS13 AS KS13_2 ON dbo.Profit_Center_YH050_2.[Controlling _Area_Partner] = KS13_2.[Controlling _Area] AND dbo.Profit_Center_YH050_2.[Profit _Center_Partner] = KS13_2.Profit_Center ON
dbo.Cuentas_Maestro.Controlling_Area = dbo.Profit_Center_YH050_2.[Controlling _Area_Partner] AND dbo.Cuentas_Maestro.Partner_Profit_Ctr = dbo.Profit_Center_YH050_2.[Profit _Center_Partner] LEFT OUTER JOIN
dbo.Depth_Structure AS Depth_Structure_1 ON dbo.Profit_Center_YH050_2.[Business _Subsegment_Partner] = Depth_Structure_1.[Spiridon _2019]
 
Where and how can i to create it?
 
In sql server created a view fron this query but i can not to print the model data. 
 

Answers (1)