棘手的SQL与Sql Geometry字段不同

棘手的SQL与Sql Geometry字段不同,第1张

棘手的SQL与Sql Geometry字段不同

您可以强制转换为VARBINARY(MAX),然后重新强制转换

create table tbl1 ( ID int, a int, b char(3), d geometry );create table tbl2 ( ID int, a int, b char(3), d geometry, other float );insert tbl1 (ID, a, b, d) values    (1, 2, 3, geometry::STGeomFromText('POLYGON ((0 0, 150 0, 150 150, 0 150, 0 0))', 0)),    (2, 3, 3, geometry::STGeomFromText('POLYGON ((0 0, 150 0, 150 150, 0 150, 0 0))', 0)),    (3, 4, 3, geometry::STGeomFromText('POLYGON ((0 0, 150 0, 150 150, 0 150, 0 0))', 0)),    (4, 2, 3, geometry::STGeomFromText('POLYGON ((0 0, 250 0, 150 150, 0 150, 0 0))', 0)),    (5, 2, 3, geometry::STGeomFromText('POLYGON ((0 0, 350 0, 150 150, 0 150, 0 0))', 0))insert tbl2 (ID, a, b, d) values    (6, 2, 3, geometry::STGeomFromText('POLYGON ((0 0, 150 0, 150 150, 0 150, 0 0))', 0)), -- same as tbl1.ID=1    (7, 2, 3, geometry::STGeomFromText('POLYGON ((0 0, 950 0, 150 150, 0 150, 0 0))', 0)),    (8, 2, 3, geometry::STGeomFromText('POLYGON ((0 0, 350 0, 150 150, 0 150, 0 0))', 0)); -- same as tbl1.ID=5SELECt A, B, cast(c as geometry) cFROM(    Select A,B,cast(D as varbinary(max)) c FROM tbl1    UNIOn    SELECt A,B,cast(D as varbinary(max)) FROM tbl2) X;


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5675627.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存