当我尝试sp_OACreate
在 SQL azure 数据库中执行存储过程时。我收到以下错误:
找不到存储过程“sp_OACreate”
在 SQL Azure 中。
谁能告诉我如何执行sp_OACreate
SQL Azure 中的 OLE 自动化方法。
任何帮助将不胜感激。
谢谢。
从 OPs 答案复制和格式化(应该是一个编辑):
我正在尝试使用谷歌地图服务来获取任何地址的坐标(纬度和经度)。我正在执行下面的 sql 查询。它在 SQL Server 2005 中运行良好,但在 SQL Azure 2008 中出现错误。请参见下文:-(请为此建议一些替代方案)
DECLARE @Sample TABLE
(
RowID INT IDENTITY(1, 1) PRIMARY KEY CLUSTERED,
Postal VARCHAR(50) NOT NULL,
ZipCode VARCHAR(50) NOT NULL,
City VARCHAR(50) NOT NULL,
Country VARCHAR(50) NOT NULL,
Status SMALLINT,
Accuracy TINYINT,
Lat DECIMAL(9, 6),
Lon DECIMAL(9, 6),
CreDate DATETIME
)
INSERT @Sample
SELECT 'One Microsoft Way', '98052', 'Redmond, WA', 'USA',null,1,0,0,getdate() UNION ALL
SELECT '170 W. Tasman Dr.', '95134', 'San Jose, CA', 'USA',null,1,0,0,getdate() UNION ALL
SELECT '500 Oracle Parkway', '94065', 'Redwood Shores, CA', 'USA',null,1,0,0,getdate()
select * from @Sample
-- Initialize
DECLARE @url VARCHAR(300),
@win INT,
@hr INT,
@Text VARCHAR(8000),
@RowID int,
@Status smallint,
@Accuracy tinyint,
@Lon decimal(9, 6),
@Lat decimal(9, 6)
SELECT @RowID = MIN(RowID) FROM @Sample WHERE Status IS NULL
WHILE @RowID IS NOT NULL
BEGIN
SELECT @url = 'q=' + Postal + '+' + ZipCode + '+' + City + '+' + Country
FROM @Sample
WHERE RowID = @RowID
SET @url = 'http://maps.google.com/maps/geo?' + @url
SET @url = @url + '&output=csv&key={your google api key here}'
EXEC @hr = sp_OACreate 'WinHttp.WinHttpRequest.5.1', @win OUT
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
EXEC @hr = sp_OAMethod @win, 'Open', NULL, 'GET', @url, 'false'
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
EXEC @hr = sp_OAMethod @win, 'Send'
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
EXEC @hr = sp_OAGetProperty @win, 'ResponseText', @Text OUT
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
EXEC @hr = sp_OADestroy @win
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
SET @Text = REPLACE(REPLACE(@Text, '.', '#'), ',', '.')
SELECT @Status = PARSENAME(@Text, 4),
@Accuracy = PARSENAME(@Text, 3),
@Lat = REPLACE(PARSENAME(@Text, 2), '#', '.'),
@Lon = REPLACE(PARSENAME(@Text, 1), '#', '.')
UPDATE @Sample
SET Accuracy = @Accuracy,
Lat = @Lat,
Lon = @Lon,
Status = @Status,
CreDate = GETDATE()
WHERE RowID = @RowID
WAITFOR DELAY '00:00:00.010'
SELECT @RowID = MIN(RowID)
FROM @Sample
WHERE Status IS NULL
END
SELECT * FROM @Sample
--If Above not executing then first execute below
--sp_configure 'show advanced options', 1;
--GO RECONFIGURE;
--
--GO
--
--sp_configure 'Ole Automation Procedures', 1; GO RECONFIGURE;
--
--GO