Can you help me to migrate the following lines from Oracle to MSSQL. Thank you.
create or replace TYPE "GPS_SEGMENT" is object (
lat1 numeric (14,5),
lon1 numeric (14,5),
lat2 numeric (14,5),
lon2 numeric (14,5)
);
create or replace TYPE "GPS_SEGMENT_TABLE" is table of gps_segment;
Thank you.
I believe what you'd want in SQL Server would be a User Defined Table Type:
CREATE TYPE udtGpsSegment AS TABLE
(
lat1 numeric (14,5),
lon1 numeric (14,5),
lat2 numeric (14,5),
lon2 numeric (14,5)
);
You could then use this as a table variable in MSSQL:
DECLARE @gpsSegment udtGpsSegment;
INSERT @gpsSegment(....)
Or take it as a parameter to a stored procedure:
CREATE PROCEDURE example (@gpsSegment udtGpsSegment READONLY)
AS
BEGIN
-- note that you can't update/insert/delete udtGpsSegment, but you can select from it - if needed, select it into a temp table or table variable that can be updated/deleted/inserted.
END
Also note that this only works for SQL Server 2008R2+