English 中文(简体)
将 MS SQL 服务器的代码从 MS SQL 服务器更改为 MySQL
原标题:Changing code from MS SQL Server to MySQL

我怎么能把这个从MS SQLSERVER转换成 MySQL?

/****** Object: StoredProcedure [dbo].[geolocation_refresh_geography] Script Date: 05/08/2012 22:02:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create procedure [dbo].[geolocation_refresh_geography]
as
update locations
SET geolocation = geography::STPointFromText( POINT(  + CAST([Longitude] AS VARCHAR(20)) +     + CAST([Latitude] AS VARCHAR(20)) +  ) , 4326)
where geolocation is null
GO

我的代码在4线造成错误 不知道为什么?

create procedure geolocation_refresh_geography()
BEGIN
update locations
SET geolocation = geography::STPointFromText( POINT(  + CAST(Longitude AS VARCHAR(20)) +     + CAST(Latitude AS VARCHAR(20)) +  ) , 4326)
where geolocation is null
END
最佳回答

你试过《MySQL移徙工具包》了吗?

http://dev.mysql.com/doc/migration-toolkit/en/mysql-migration-toolkit-integration-inte-spolictedb-msql.html

It is a bit tough to find these days but I believe you can also you MySQL Workbench to accomplish this. http://www.mysql.com/products/workbench/

我建议你将整个计划 移走,这样你就可以完成这个程序了

问题回答

首先, MySQL 支持空间数据, 前提是启用空间扩展功能配置( http://dev. mysql.com/doc/refman/ 5. 0/ en/ spatial- extensions. html ) 。 假设您已经安装了这个设置, 您只需要将 SQL 服务器语法调整为适合的 MySQL 方法即可 。

MySQL 拥有一个 PointFromText () 方法( http://dev. mysql.com/doc/ dec/ refman/ 5. 0/ en/ create- spatial- values.html#conference_point fromtext ()), 反映 SQL 服务器 STPointFromText () 的行为( http:// msdn. microsoft. com/ en- us/library/b933979.aspx), 这样您就可以用 PointFlookText 来取代“ em> em/ em:: STPointFromText 的引用。

然而,对于在单一纬度/纬度坐标对上插入点,如您所做的那样,最容易使用的方法是Point () (http://dev.mysql.com/doc/refman/5.0/en/create-spatial-values.html#conference_point),在这种情况下,您的代码就变成:

create procedure geolocation_refresh_geography()
BEGIN
update locations
SET geolocation = Point(Longitude, Latitude)
where geolocation is null
END




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签