getting error "Could not find stored procedure 'sp_OACreate'" in Sql Azure
When I try to execute the sp_OACreate
stored procedure in SQL azure database. I am getting following error:
Could not find stored procedure 'sp_OACreate'
in SQL Azure.
Can anyone tell me how to execute the OLE automation methods like sp_OACreate
in SQL Azure.
Any help will be highly appreciated.
Thanks.
Copied & Formatted from OPs answer (which should have been an edit):
I am trying to hit the google map services to get the co-orinates(Latitude & Longitude) of any address. I am executing below sql queries. Its working fine in SQL server 2005 but its giving error in SQL Azure 2008.Plz see below:-(Please suggest some alternate for this)
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
There's no means to call out to web services from within SQL Azure - you'll have to move such calls up into code which is running on a Windows Azure (as opposed to SQL Azure) service, and you won't be writing it in Transact SQL.
sp_OACreate is an automation stored procedure and is not available in SQL Azure Database
http://msdn.microsoft.com/en-us/library/ee336237.aspx
I would be very surprised if there are any workarounds.
精彩评论