Thursday, September 24, 2009

SQL Server select data from CSV as if it were a table

I can select without using DTS or a linked server.

SELECT * FROM OPENROWSET
('MICROSOFT.JET.OLEDB.4.0','Text;Database=C:\Folder\;',
'SELECT * FROM [Report.csv]') MyAlias

You may need these permissions
sp_configure 'Ad Hoc Distributed Queries', 1
reconfigure

You may have problems on X64