Select to view content in your preferred language

How to add two tables in Geodatabase view without any join between them?

2574
2
10-19-2015 07:08 AM
SaidAkif
Occasional Contributor

Hi all

I want to add two tables in geodatabase view (see attached). Those two table can not be related (attributes tables)

I am struggling with the SQL statement

Thanks

Untitled2.jpg

0 Kudos
2 Replies
ChrisSmith7
Honored Contributor

Without a join? Something like this in SQL maybe?

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_gis_view_test]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_gis_view_test]
GO
----------------------------------------------------------------------------------------------------------------   
/*   
COMMENTS... 
*/   
---------------------------------------------------------------------------------------------------------------- 
CREATE VIEW dbo.v_gis_view_test
AS
SELECT
  table1.f1,
  table1.f2,
  table1.f3
FROM
  dbo.theTableOne table1
UNION
SELECT
  table2.f1,
  table2.f2,
  table2.f3
FROM
  dbo.theTableTwo table2


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

In ArcGIS, I believe you would just add the view name, "v_gis_view_test" in this case, in the name box, and the select clauses in the expression box. Is this what you're looking to do?

SaidAkif
Occasional Contributor

Thanks

I tried in arcCatalog with New/View with the following code:

SELECT

  gkmigeodatabase.NCR.AB_WetlandsGrid_25km.OBJECTID,

  gkmigeodatabase.NCR.AB_WetlandsGrid_25km.PageName,

  gkmigeodatabase.NCR.AB_WetlandsGrid_25km.percentage

FROM

  gkmigeodatabase.NCR.AB_WetlandsGrid_25km

UNION

SELECT

  gkmigeodatabase.NCR.BC_WetlandsGrid_25km.OBJECTID,

  gkmigeodatabase.NCR.BC_WetlandsGrid_25km.PageName,

  gkmigeodatabase.NCR.BC_WetlandsGrid_25km.percentage

FROM

  gkmigeodatabase.NCR.BC_WetlandsGrid_25km

The problem is that no geometry is loaded

After, I right click on my view to load data:

unfortunately, I got this error

I want notace that my feature classes have exactly the same schema

thanks for your help

0 Kudos