select * into #temp from OpenRowSet(...) where 1=2select count(*) from tempdb.sys.columns where object_id = object_id('tempdb..#temp')drop table #temp
OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".Msg 7303, Level 16, State 1, Line 1Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".
declare @FileName varchar(100)set @FileName = '<Put your filename here>'declare @oFSO int, @oTSO int, @line varchar(500)-- get the first line from the fileexecute sp_OACreate 'Scripting.FileSystemObject', @oFSO OUTPUTexecute sp_OAMethod @oFSO, 'OpenTextFile', @oTSO OUTPUT, @FileNameexecute sp_OAMethod @oTSO, 'ReadLine', @line OUTPUTexecute sp_OAMethod @oTSO, 'Close'execute sp_OADestroy @oTSOexecute sp_OADestroy @oFSO;with CTE AS(select Col = substring(@line, Number, 1) from dbo.Numbers where Number <= len(@line))select ColumnCount = count(*) + 1, @line from CTE where Col = ','