Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Using Openrowset

Author  Topic 

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2014-01-14 : 06:20:14
hi

I would like to query from yahoo finance using openrowset function

http://download.finance.yahoo.com/d/quotes.csv?s=USDTHB=X&f=sl1d1t1c1ohgv&e=.csv

How do i use openrowset to open a csv file from yahoo finance?

Thanks

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-01-14 : 08:12:54
[code]create table quotes
(
col1 varchar(100),
col2 varchar(100),
col3 varchar(100),
col4 varchar(100),
col5 varchar(100),
col6 varchar(100),
col7 varchar(100),
col8 varchar(100),
col9 varchar(100)
)
go

BULK INSERT quotes
FROM 'C:\quotes.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\r\n'
)[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2014-01-14 : 08:39:00
hi

I mean how do I select directly from the URL instead of downloading the CSV files. Thanks
Go to Top of Page

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2014-01-14 : 08:42:57
I did try something like this


Exec sp_configure 'Show advanced options', 1
go
reconfigure
go

Exec sp_configure 'ad hoc distributed queries',1
go
reconfigure
go

EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
GO
Select * from openrowset('Microsoft.ACE.OLEDB.12.0', 'Text;Database=http://download.finance.yahoo.com/d/quotes.csv?s=USDTHB=X&f=sl1d1t1c1ohgv&e=.csv;HDR=No', 'Select * from quotes.csv')

But to no result. How should I go about it? Thanks
Go to Top of Page

nagino
Yak Posting Veteran

75 Posts

Posted - 2014-01-16 : 00:40:17
You can use SSIS or User-Defined Function.
See also following.
http://www.databasejournal.com/features/mssql/article.php/3821271/Calling-a-Web-Service-from-within-SQL-Server.htm


-------------------------------------
From Japan
Sorry, my English ability is limited.
Go to Top of Page
   

- Advertisement -