简体   繁体   English

将用户定义类型从Oracle迁移到MSSQL

[英]Migrate User Define Types from Oracle to MSSQL

Can you help me to migrate the following lines from Oracle to MSSQL. 您能帮我将以下几行从Oracle迁移到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: 我相信您在SQL Server中想要的是用户定义的表类型:

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: 然后,您可以将其用作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+ 另请注意,这仅适用于SQL Server 2008R2 +

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM