ALTER PROCEDURE dbo.StoredProcedure1
AS
DECLARE @Seedid int, @data1 float, @data2 float, @g geometry
DECLARE member_cursor CURSOR FOR
SELECT id from test1 ;
OPEN member_cursor;
FETCH NEXT FROM member_cursor
INTO @Seedid ;
WHILE @@FETCH_STATUS = 0
BEGIN
select @data1 =data1 from test where id=@Seedid
select @data2 =data2 from test where id=@Seedid
update test1
set data4 = geometry::STGeomFromText('POINT (@data1 @data2)', 0)
where id=@Seedid;
-- This is executed as long as the previous fetch succeeds.
FETCH NEXT FROM member_cursor
INTO @Seedid ;
END
RETURN
CLOSE member_cursor;
DEALLOCATE member_cursor;
我收到以下错误:
该声明已被终止。
在执行用户定义的例程或聚合“几何”期间发生.NET Framework错误:
System.FormatException:24141:输入的第13位需要一个数字。输入有@ data1。
答案 0 :(得分:1)
经过一番努力,我终于找到了解决这个问题的方法。如果其他人再次遇到此类问题,则发布解决方案。在我传递@data1
和@data2
时的几何中,其变量为@data1
,而不是浮点值。那么,我们可以做的是:
select @data1 =data1 from test1 where id=@Seedid
select @data2 =data2 from test1 where id=@Seedid
Set @POINTSTR = 'POINT(' + CAST(@data1 AS varchar(32)) + ' ' + CAST(@data2 AS varchar(32)) + ')';
update test1 set data4 = geometry::STGeomFromText(@POINTSTR, 4326) where id=@Seedid;