CREATE TABLE SPATIALPOINTGEOM_dt (location geometry)

#Geometry Test Cases

#Positive Test for STGeomFromText with SRID 4326
INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) )

INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(1.0 2.0)', 4326) )

#Positive Test for STGeomFromText with SRID 0
INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 0) )

#Negative Test for STGeomFromText when SRID is not provided
INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)') )

#Negative Test for STGeomFromText when SRID >= 10^6
#SRID should be between 0 to 999999
INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 1000000000 ) )

#Negative Test for STGeomFromText with SRID < 0
#SRID should be between 0 to 999999
INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', -1) )

#Negative Test for STGeomFromText when a coordinate is missing
INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(1.0 )', 4326) )

#Negative Test for STGeomFromText when invalid type is provided
INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Pnt', 4326) )

#Test for STGeomFromText when null Point is Given -> Returns NBCRow
INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText(null, 4326) )

#Negative Test for STGeomFromText when Incorrect cast is provided
#INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) )

#Positive Test for STPointFromText with SRID 4326. Rest are same as STGeomFromText
INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STPointFromText('Point(47.65100 -22.34900)', 4326) )

INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STPointFromText('Point(1.0 2.0)', 4326) )


#Positive Test for Point with SRID 4326
INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::Point(47.65100, -22.34900, 4326) )

CREATE TABLE YourTable ( ID INT PRIMARY KEY, PointColumn geometry ); 

INSERT INTO YourTable (ID, PointColumn) VALUES (1, geometry::Point(3.0, 4.0, 4326)), (2, geometry::Point(5.0, 6.0, 4326));

CREATE TABLE GeomTab ( ID INT PRIMARY KEY, PointColumn geometry );

INSERT INTO GeomTab (ID, PointColumn) VALUES (1, geometry::Point(3.0, 4.0, 4326)), (2, geometry::Point(3.0, 6.0, 4326));

CREATE FUNCTION dbo.GetXCoordinate(@point geometry) RETURNS float AS BEGIN RETURN @point.STX; END; 

CREATE PROCEDURE GetDistanceByXCoordinate @xCoordinate FLOAT AS BEGIN DECLARE @point geometry = geometry::Point(@xCoordinate, 0.0, 4326); SELECT @point.STY, CAST(YourTable.PointColumn.STDistance(@point) AS numeric(20, 6)) AS Distance FROM YourTable ORDER BY PointColumn.STX; END;

CREATE TABLE TableA (ID INT PRIMARY KEY, PointA geometry); 
CREATE TABLE TableB (ID INT PRIMARY KEY, PointB geometry);
INSERT INTO TableA (ID, PointA) VALUES (1, geometry::Point(1.0, 2.0, 4326)); 
INSERT INTO TableB (ID, PointB) VALUES (1, geometry::Point(3.0, 4.0, 4326));

CREATE PROCEDURE GetPointsByXCoordinate @XCoordinate FLOAT AS BEGIN SELECT * FROM YourTable WHERE PointColumn.STX = @XCoordinate ORDER BY PointColumn.STX; END;

CREATE PROCEDURE GetPointsByXCoordinate1 @XCoordinate FLOAT AS BEGIN DECLARE @Sql NVARCHAR(MAX); SET @Sql = N'SELECT ID, PointColumn.STX AS XCoordinate FROM YourTable WHERE PointColumn.STX = @ParamXCoordinate ORDER BY PointColumn.STX'; EXEC sp_executesql @Sql,N'@ParamXCoordinate FLOAT',@XCoordinate; END;

CREATE TABLE YourTable1 ( ID INT PRIMARY KEY, STX geometry ); 
INSERT INTO YourTable1 (ID, STX) VALUES (1, geometry::Point(3.0, 4.0, 4326)), (2, geometry::Point(5.0, 6.0, 4326));

CREATE FUNCTION GetGeometry() RETURNS geometry AS BEGIN RETURN geometry::Point(1.0, 2.0, 4326); END;

CREATE TABLE XCoordinateChangeLog (PointID INT,OldXCoordinate FLOAT,NewXCoordinate FLOAT,ChangeDate DATETIME);

CREATE TRIGGER trg_LogXCoordinateChange ON YourTable AFTER UPDATE AS BEGIN INSERT INTO XCoordinateChangeLog (PointID, OldXCoordinate, NewXCoordinate, ChangeDate) SELECT i.ID, d.PointColumn.STX, i.PointColumn.STX, GETDATE() FROM inserted i JOIN deleted d ON i.ID = d.ID WHERE i.PointColumn.STX <> d.PointColumn.STX ORDER BY i.ID; END;

CREATE TABLE YourTable2 ( ID INT PRIMARY KEY, PointColumn1 geometry, PointColumn2 geometry ); 
INSERT INTO YourTable2 (ID, PointColumn1, PointColumn2) VALUES (1, geometry::Point(3.0, 4.0, 4326), geometry::Point(4.0, 5.0, 4326));

CREATE FUNCTION dbo.CalculateDistance(@point1 geometry,@point2 geometry) RETURNS numeric(20, 6) AS BEGIN RETURN CAST(@point1.STDistance(@point2) AS numeric(20, 6)); END;

CREATE PROCEDURE GetPointsWithinDistance @referencePoint geometry, @maxDistance float AS BEGIN SELECT * FROM YourTable WHERE CAST(PointColumn.STDistance(@referencePoint) AS numeric(20, 6)) <= @maxDistance ORDER BY PointColumn.STX; END;

CREATE TABLE DistanceChangeLog (PointID INT,OldDistance FLOAT,NewDistance FLOAT,ChangeDate DATETIME);

CREATE TRIGGER trg_LogDistanceChange ON YourTable AFTER UPDATE AS BEGIN DECLARE @referencePoint geometry = geometry::Point(0.0, 0.0, 4326); INSERT INTO DistanceChangeLog (PointID, OldDistance, NewDistance, ChangeDate) SELECT i.ID, CAST(d.PointColumn.STDistance(@referencePoint) AS numeric(20, 6)), CAST(i.PointColumn.STDistance(@referencePoint) AS numeric(20, 6)), GETDATE() FROM inserted i JOIN deleted d ON i.ID = d.ID WHERE CAST(i.PointColumn.STDistance(@referencePoint) AS numeric(20, 6)) <> CAST(d.PointColumn.STDistance(@referencePoint) AS numeric(20, 6)) ORDER BY i.ID; END;

#Tests for Geometry type Prepared Statements
prepst#!#INSERT INTO SPATIALPOINTGEOM_dt(location) values(@location) #!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):4326
prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0):4326
prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):0
prepst#!#exec#!#GEOMETRY|-|location|-|Point(-91.0 -35.0):4326
prepst#!#exec#!#GEOMETRY|-|location|-|Point(290.345 45.1234):4326
prepst#!#exec#!#GEOMETRY|-|location|-|Point(-120.345 45.1234):4326
prepst#!#exec#!#GEOMETRY|-|location|-|Point(-720.345 45.1234):4326
prepst#!#exec#!#GEOMETRY|-|location|-|Point(220.345 45.1234):4326
prepst#!#exec#!#GEOMETRY|-|location|-|Point(120.345 45.1234):4326
#Negative Test for STGeomFromText when SRID >= 10^6
prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):1000000000
#Negative Test for STGeomFromText with SRID < 0
prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):-1
#Negative Test for STGeomFromText when SRID is NULL
prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):<NULL>
#Negative Test for STGeomFromText when a coordinate is missing
prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 ):4326
#Negative Test when an unsupported feature in queried
prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0 3.0 4.0):4326
prepst#!#exec#!#GEOMETRY|-|location|-|LINESTRING(1 2, 3 4):4326

create table geominTable (a geometry);
Insert into geominTable values('POINT(1 2)');
Insert into geominTable values('POINT(1 2 3)');
Insert into geominTable values('POINT(1 2 3 4)');
Insert into geominTable values('LINESTRING(1 2,3 4)');
Insert into geominTable values('POINT(1000 2000)');
Insert into geominTable values('POINT(123 34)');

create procedure geominTest @a geometry as select @a.STX as Xcoord, @a.STY as Ycoord ORDER BY @a.STX;

CREATE VIEW TextFromGeom AS SELECT STX(location) AS XCoord, STAsText(location) AS TextRepresentation FROM SPATIALPOINTGEOM_dt ORDER BY location.STX;

CREATE VIEW BinaryFromGeom AS SELECT STAsBinary(location) AS BinaryRepresentation FROM SPATIALPOINTGEOM_dt ORDER BY location.STX;

CREATE VIEW CoordsFromGeom AS SELECT STX(location), STY(location)  AS Coordinates FROM SPATIALPOINTGEOM_dt ORDER BY location.STX;

CREATE VIEW GeomView AS SELECT location.STX, location.STY AS Coordinates FROM SPATIALPOINTGEOM_dt ORDER BY location.STX;

CREATE VIEW ValFromGeom AS SELECT location.STAsText(), location.STAsBinary() AS binary FROM SPATIALPOINTGEOM_dt ORDER BY location.STX;

CREATE FUNCTION f_getval() RETURNS TABLE AS RETURN ( SELECT location.STX AS XCoordinate, location.STY AS YCoordinate FROM SPATIALPOINTGEOM_dt ORDER BY location.STX );

CREATE PROCEDURE dbo.p_getcoordinates AS BEGIN DECLARE @Coordinates TABLE ( XCoordinate float, YCoordinate float ); INSERT INTO @Coordinates SELECT * FROM dbo.f_getval() ORDER BY XCoordinate; SELECT * FROM @Coordinates ORDER BY XCoordinate; END;

CREATE VIEW equal_geom AS SELECT p1.location AS point FROM SPATIALPOINTGEOM_dt p1 CROSS JOIN SPATIALPOINTGEOM_dt p2 WHERE p1.location = p2.location ORDER BY p1.location.STX;

CREATE VIEW point_distances_geom AS SELECT p1.location AS point1, p2.location AS point2, CAST(STDistance( p1.location, p2.location ) AS numeric(20, 6)) AS distance FROM SPATIALPOINTGEOM_dt p1 CROSS JOIN SPATIALPOINTGEOM_dt p2 WHERE p1.location <> p2.location ORDER BY p1.location.STX;

CREATE TABLE SPATIALPOINTGEOG_dt (location geography)

#Create Type Test Case currently Babelfish supports it but TSQL doesn't for spatial Types, Although it doesn't break anything
#TODO: Make it similar to T-SQL
CREATE TYPE geom FROM geometry NOT NULL ;

CREATE TABLE TypeTable(ID INT PRIMARY KEY, Shape geom)

INSERT INTO TypeTable(ID, Shape) VALUES(1, geometry::Point(1, 2, 4326));

#Testing Implicit CASTs to and from Geometry data type for supported Explicit CASTs
#UnSupported CASTs to and from Geometry data type
CREATE TABLE GeomToVarbinary(p varbinary)
INSERT INTO GeomToVarbinary(p) VALUES(geometry::Point(1, 2, 4326));
CREATE TABLE GeomTochar(p char)
INSERT INTO GeomTochar(p) VALUES(geometry::Point(1, 2, 4326));
CREATE TABLE GeomToVarchar(p varchar)
INSERT INTO GeomToVarchar(p) VALUES(geometry::Point(1, 2, 4326));
#Supported CASTs to and from Geometry data type
CREATE TABLE TypeToGeom(p geometry)
INSERT INTO TypeToGeom(p) VALUES(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS varbinary(MAX)));
INSERT INTO TypeToGeom(p) VALUES(CAST ('POINT(1 2)' AS char));
INSERT INTO TypeToGeom(p) VALUES(CAST ('POINT(1 2)' AS varchar));

#Geography Test Cases

#Positive Test for STGeomFromText with SRID 4326
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) )

INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(1.0 2.0)', 4326) )

#Negative Test for STGeomFromText for Geography with SRID 0
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 0) )

#Negative Test for STGeomFromText for Geography when lat > 90 or < -90
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -122.34900)', 4326) )

#Negative Test for STGeomFromText when SRID is not provided
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)') )

#Negative Test for STGeomFromText when cast is not provided
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( STGeomFromText('Point(47.65100 -22.34900)', 4326) )

#Negative Test for STGeomFromText when incorrect cast is provided
#INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) )

#Negative Test for STGeomFromText when SRID >= 10^6
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 1000000000 ) )

#Negative Test for STGeomFromText with SRID < 0
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', -1) )

#Negative Test for STGeomFromText when a coordinate is missing
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(1.0 )', 4326) )

#Negative Test for STGeomFromText when invalid type is provided
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Pnt', 4326) )

#Test for STGeomFromText when null Point is Given -> Returns NBCRow
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText(null, 4326) )

#Positive Test for STPointFromText with SRID 4326. Rest are same as STGeomFromText
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STPointFromText('Point(47.65100 -22.34900)', 4326) )

INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STPointFromText('Point(1.0 2.0)', 4326) )

#Negative Test for STPointFromText for Geography when lat > 90 or < -90
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STPointFromText('Point(47.65100 122.34900)', 4326) )

#Positive Test for Point with SRID 4326
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::Point(47.65100, -22.34900, 4326) )

#Negative Test for Point for Geography when lat > 90 or < -90
INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::Point(147.65100, -22.34900, 4326) )

#Tests for Geography type Prepared Statements
prepst#!#INSERT INTO SPATIALPOINTGEOG_dt(location) values(@location) #!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):4326
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0):4326
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(-91.0 -35.0):4326
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(290.345 45.1234):4326
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(-120.345 45.1234):4326
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(-720.345 45.1234):4326
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(220.345 45.1234):4326
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(120.345 45.1234):4326
#Negative Test for STGeomFromText for Geography with SRID 0
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):0
#Negative Test for STGeomFromText for Geography when lat > 90 or < -90
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -122.34900):4326
#Negative Test for STGeomFromText when SRID >= 10^6
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):1000000000
#Negative Test for STGeomFromText with SRID < 0
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):-1
#Negative Test for STGeomFromText with SRID is NULL
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):<NULL>
#Negative Test for STGeomFromText when a coordinate is missing
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 ):4326
#Negative Test when an unsupported feature in queried
prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0 3.0 4.0):4326
prepst#!#exec#!#GEOGRAPHY|-|location|-|LINESTRING(1 2, 3 4):4326

CREATE VIEW TextFromGeog AS SELECT Lat(location) AS Latitude, STAsText(location) AS TextRepresentation FROM SPATIALPOINTGEOG_dt ORDER BY location.Lat;

CREATE VIEW BinaryFromGeog AS SELECT STAsBinary(location) AS BinaryRepresentation FROM SPATIALPOINTGEOG_dt ORDER BY location.Lat;

CREATE VIEW CoordsFromGeog AS SELECT Long(location), Lat(location)  AS Coordinates FROM SPATIALPOINTGEOG_dt ORDER BY location.Lat;

CREATE VIEW GeogView AS SELECT location.Long, location.Lat AS Coordinates FROM SPATIALPOINTGEOG_dt ORDER BY location.Lat;

CREATE TABLE test_table (geog geography)
INSERT INTO test_table(geog) VALUES(geography::Point(1, 2, 4326));

create table geoginTable (a geography);
Insert into geoginTable values('POINT(1 2)');
Insert into geoginTable values('POINT(1 2 3)');
Insert into geoginTable values('POINT(1 2 3 4)');
Insert into geoginTable values('LINESTRING(1 2,3 4)');
Insert into geoginTable values('POINT(1000 2000)');
Insert into geoginTable values('POINT(123 34)');

CREATE VIEW SubqueryView AS SELECT (select geog from test_table ORDER BY geog.Lat).Lat AS Latitude ORDER BY Latitude;

CREATE VIEW BrackExprView AS SELECT ( geog ).Lat AS Latitude from test_table ORDER BY geog.Lat;

CREATE VIEW FuncExprView AS SELECT geography::Point(1, 2, 4326).Lat AS Latitude from test_table ORDER BY geog.Lat;

CREATE FUNCTION func_getval() RETURNS TABLE AS RETURN ( SELECT location.STAsText() AS TextPoint FROM SPATIALPOINTGEOG_dt ORDER BY location.Lat );

CREATE PROCEDURE dbo.proc_getdata AS BEGIN DECLARE @Data TABLE ( TextPoint text ); INSERT INTO @Data SELECT * FROM dbo.func_getval() ORDER BY TextPoint; SELECT * FROM @Data ORDER BY TextPoint; END;

create procedure geoginTest @a geography as select @a.Lat as Latitude, @a.Long as Longitude ORDER BY @a.Lat;

CREATE VIEW TransformFromGeog AS SELECT ST_Transform(location, 4326) AS Modified_points FROM SPATIALPOINTGEOG_dt ORDER BY location.Lat;

CREATE VIEW equal_geog AS SELECT p1.location AS point FROM SPATIALPOINTGEOG_dt p1 CROSS JOIN SPATIALPOINTGEOG_dt p2 WHERE p1.location = p2.location ORDER BY p1.location.Lat;

CREATE VIEW point_distances_geog AS SELECT p1.location AS point1, p2.location AS point2, CAST(STDistance( p1.location, p2.location ) AS numeric(20, 6)) AS distance FROM SPATIALPOINTGEOG_dt p1 CROSS JOIN SPATIALPOINTGEOG_dt p2 WHERE p1.location <> p2.location ORDER BY p1.location.Lat;

CREATE TABLE SpatialData(ID INT PRIMARY KEY, SpatialLocation GEOGRAPHY);
INSERT INTO SpatialData (ID, SpatialLocation) VALUES (1, geography::Point(1, 2, 4326)), (2, geography::Point(3, 4, 4326)), (3, geography::Point(5, 6, 4326)), (4, geography::Point(7, 8, 4326)), (5, geography::Point(9, 10, 4326));

create function testspatial_tvf(@x int) returns table as return select location from SPATIALPOINTGEOG_dt ORDER BY location.Lat;

#Testing Implicit CASTs to and from Geography data type for supported Explicit CASTs
#UnSupported CASTs to and from Geography data type
CREATE TABLE GeogToVarbinary(p varbinary)
INSERT INTO GeogToVarbinary(p) VALUES(geography::Point(1, 2, 4326));
CREATE TABLE GeogTochar(p char)
INSERT INTO GeogTochar(p) VALUES(geography::Point(1, 2, 4326));
CREATE TABLE GeogToVarchar(p varchar)
INSERT INTO GeogToVarchar(p) VALUES(geography::Point(1, 2, 4326));
#Supported CASTs to and from Geography data type
CREATE TABLE TypeToGeog(p geography)
INSERT INTO TypeToGeog(p) VALUES(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS varbinary(MAX)));
INSERT INTO TypeToGeog(p) VALUES(CAST ('POINT(1 2)' AS char));
INSERT INTO TypeToGeog(p) VALUES(CAST ('POINT(1 2)' AS varchar));

CREATE TABLE SPATIALPOINT_dt (PrimaryKey int, GeomColumn geometry, GeogColumn geography)

INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeomColumn) VALUES ( 1, geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) )

INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeogColumn) VALUES ( 2, geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) )

INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeomColumn, GeogColumn) VALUES ( 3, geometry::STGeomFromText('Point(1.0 2.0)', 4326), geography::STGeomFromText('Point(1.0 2.0)', 4326) )

CREATE TABLE geomTabWithoutSrid (PrimaryKey int, GeomColumn geometry, ByteaColumn bytea)
INSERT INTO geomTabWithoutSrid VALUES ( 1, geometry::STGeomFromText('Point(47.65100 -22.34900)', 0), CAST (0x00000000010C17D9CEF753D34740D34D6210585936C0 AS bytea) )
INSERT INTO geomTabWithoutSrid VALUES ( 2, geometry::STGeomFromText('Point(48.65100 -22.34900)', 4326), CAST (0xE6100000010C17D9CEF753534840D34D6210585936C0 AS bytea) )
INSERT INTO geomTabWithoutSrid VALUES ( 3, geometry::STGeomFromText('Point(1.0 2.0)', 0), CAST (0x00000000010C000000000000F03F0000000000000040 AS bytea) )
INSERT INTO geomTabWithoutSrid VALUES ( 4, geometry::STGeomFromText('Point(2.0 2.0)', 4326), CAST (0xE6100000010C00000000000000400000000000000040 AS bytea) )

#Tests for Spatial type Prepared Statements
prepst#!#INSERT INTO SPATIALPOINT_dt(PrimaryKey, GeomColumn) values(@PrimaryKey, @GeomColumn) #!#int|-|PrimaryKey|-|4#!#GEOMETRY|-|GeomColumn|-|Point(47.65100 -22.34900):4326
prepst#!#INSERT INTO SPATIALPOINT_dt(PrimaryKey, GeogColumn) values(@PrimaryKey, @GeogColumn) #!#int|-|PrimaryKey|-|5#!#GEOGRAPHY|-|GeogColumn|-|Point(47.65100 -22.34900):4326
prepst#!#INSERT INTO SPATIALPOINT_dt(PrimaryKey, GeomColumn, GeogColumn) values(@PrimaryKey, @GeomColumn, @GeogColumn) #!#int|-|PrimaryKey|-|6#!#GEOMETRY|-|GeomColumn|-|Point(1.0 2.0):4326#!#GEOGRAPHY|-|GeogColumn|-|Point(1.0 2.0):4326

create procedure geometry_proc_1 @a geometry, @b varchar(max) as select @a as a, @b as b ORDER by a;
create procedure geography_proc_1 @a geography, @b varchar(max) as select @a as a, @b as b ORDER by a;
create table geo_view_test(a geometry, b geography)
CREATE TYPE dbo.GeospatialUDT FROM geometry NOT NULL;

create schema geom_schema;
CREATE FUNCTION geom_schema.STDistance(@point geometry) RETURNS nvarchar(max) AS BEGIN RETURN @point.STAsText(); END;
create table geometry_test(geom_schema geometry)
Insert INTO geometry_test VALUES(geometry::STGeomFromText('Point(47.65100 -22.34900)', 0))
create table STX(STX geometry)
Insert INTO STX VALUES(geometry::STGeomFromText('Point(47.65100 -22.34900)', 0))
