Solved

Connect to a domain URL from within SQL Server

Posted on 2016-08-03
3
41 Views
Last Modified: 2016-09-05
Hi,

I have a stored procedure in SQL Server that is connecting to a URL and parsing xml into tables. The URL is on a network that I can access via a VPN connection, but instead of connecting the computer to the network can you just login using SQL Server or tsql.

This is the command:

exec dbo.meteobridgeDavisVantagePro2 @url = 'http://***.***.***.***//cgi-bin/livedataxml.cgi'
      ,@http_basic_username = '****'
      ,@http_basic_password = '********'

The username and password is used to access the URL itself not the domain network too.

This is how I connect to the URL from within the stored procedure:

exec @ole_result = sp_OACreate 'MSXML2.XMLHttp', @ole_object OUT
      exec @ole_result = sp_OAMethod @ole_object, 'open', NULL, 'GET', @url, false, @http_basic_username, @http_basic_password
      exec @ole_result = sp_OAMethod @ole_object, 'send', NULL, ''
      exec @ole_result = sp_OAGetProperty @ole_object, 'status', @http_status OUT
      exec @ole_result = sp_OAGetProperty @ole_object, 'responseXML.xml', @http_response OUT
      SET @xml = @http_response

Thank you
0
Comment
Question by:crompnk
3 Comments
 
LVL 17

Accepted Solution

by:
Barry Cunney earned 250 total points
ID: 41740337
Hi crompnk,
One option may be to set all this up in a SQL Server job with several steps
Step 1 - Powershell job step which uses New-PSDrive to connect to other domain
Step 2 - T-SQL job step which calls your dbo.meteobridgeDavisVantagePro2 stored procedure
0
 
LVL 6

Assisted Solution

by:Manju
Manju earned 250 total points
ID: 41740911
With JDBC, you can. Please refer to Microsoft site(https://msdn.microsoft.com/en-us/library/ms378428(v=sql.110).aspx) to play with url's
0
 

Author Closing Comment

by:crompnk
ID: 41784352
I actually solved this by just adding external access to the URL, this was easier than trying to control access within SQL Server.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now