/* create the basic table structures needed */ CREATE TABLE X_DIMENSION ( LOC int NULL , X_ELEMENT varchar (2000) NULL ) CREATE TABLE Y_DIMENSION ( LOC int NULL, Y_ELEMENT [varchar (2000) NULL )CREATE TABLE X_Y_INDEX ( X_LOC int NULL, Y_LOC int NULL )/* Now we create some data to place into the tables, indexed */ INSERT X_Y_INDEX (X_LOC, Y_LOC) SELECT 5,7 INSERT X_DIMENSION (LOC,X_DIMENSION) SELECT 5,'DATA IN ELEMENT 5 ' INSERT Y_DIMENSION (LOC,Y_DIMENSION) SELECT 7,'REMAINING DATA FOR ELEMENT 5,7'/* now that we have some data present, we can call it up by referencing the contents of the X_Y_INDEX table just by setting a variable to the elements we want to retrieve! */ DECLARE @X INT, @Y INTSET @X = 5 or whatever method of loading you want SET @Y = 7SELECT A.X_DIMENSION + B.Y_DIMENSION FROM X_DIMENSION A, Y_DIMENSION B WHERE A.LOC = @X AND B.LOC = @Y/* The Query returns the concatenated value! */ /* DATA IN ELEMENT 5, REMAINING DATA IN ELEMENT 7 /
CREATE TABLE XY_DIMENSIONAL_DATA(LOC_X int NULL,LOC_Y int NULL,DATA_ELEMENT [varchar (2000) NULL)/* Again, we load data using any method we want, as long as we keep the X-Y Coordinates handled */ INSERT XY_DIMENSIONAL_DATA (X_LOC, Y_LOC, DATA_ELEMENT) SELECT 5,7,'DATA IN ELEMENT 5,7 )DECLARE @X INT, @Y INTSET @X = 5 or whatever method of loading you want SET @Y = 7SELECT DATA_ELEMENT FROM XY_DIMENSIONAL_DATA WHERE LOC_X = @X AND LOC_Y = @Y/* AND OF COURSE, THE RETURNED VALUE IS *//* DATA IN ELEMENT 5,7 /