I am starting to use the Microsoft SQL Server Geography
datatype. Everything is ok but there is a small problem I ran into.
I started by creating a table (ClientId is not actually primary) routes with 2 columns: ClientId
(int
) and Zone
(geography
)
CREATE TABLE [dbo].[routes]
(
[ClientId] [int] NOT NULL,
[Zone] [geography] NULL,
)
I ran the following script (302624121 is the newly created table):
SELECT
o.id as 'Id', c.name as 'Name', t.name AS 'Type',
c.length AS 'Length'
FROM
sys.sysobjects as o
INNER JOIN
sys.syscolumns AS c ON o.id = c.id
INNER JOIN
sys.systypes AS t ON c.xtype = t.xtype
WHERE
(o.id = 302624121)
and voilà, this is what I get:
302624121 ClientId int 4
302624121 Zone hierarchyid -1
302624121 Zone geometry -1
302624121 Zone geography -1
The zone has been created 3 times!!!!
Next I added a stored procedure to select data from the above table where a given point is contained within the client's geography.
Create proc [dbo].[up_RoutesSelectByGeography]
@ClientId int,
@Zone geography
as
begin
SELECT [ClientId], [Zone]
FROM [dbo].[Routes]
where ClientId = @ClientId and [Zone].STContains(@Zone) = 1
end
I ran the following query with the id of the procedure:
SELECT
o.id as 'Id', c.name as 'Name',
t.name AS 'Type', c.length AS 'Length'
FROM
sys.sysobjects as o
INNER JOIN
sys.syscolumns AS c ON o.id = c.id
INNER JOIN
sys.systypes AS t ON c.xtype = t.xtype
WHERE
(o.id = 334624235)
And I always get 3 types for the same variable:
334624235 @ClientId int 4
334624235 @Zone hierarchyid -1
334624235 @Zone geometry -1
334624235 @Zone geography -1
This issue is posing me a problem because i am not able to map the field name with a variable as I get the same variable name thrice.
Any light to what is happening? Which variables to map to my c#??