I have a text file of postcodes in CSV format that I would like to import...
I am using SQL Server Express and do not have access to DTS.
I would prefer to import the information as opposed to linking to it, what
is the simplest way to get the text info into my table.
Thanks in advance...try this... hope this helps
SELECT * FROM OpenDataSource( 'MSDASQL',
'Driver={Microsoft Text Driver (*.txt; *.csv)};
DefaultDir=C:\Test;').[C:\test]..[filename.csv]|||"Omnibuzz" <Omnibuzz@.discussions.microsoft.com> wrote in message
news:7268C38F-0C91-4D60-9DD8-4F004C2A84DD@.microsoft.com...
> try this... hope this helps
> SELECT * FROM OpenDataSource( 'MSDASQL',
> 'Driver={Microsoft Text Driver (*.txt; *.csv)};
> DefaultDir=C:\Test;').[C:\test]..[filename.csv]
Thanks for the help however I have never doen this before and...
I've enabled OpenDataSource as required.
The file name is C:\PostCodes.CSV and has field names in the first row.
I am interested in the first three columns
PCode, Locality & State
So I have tried without success:
SELECT PCode, Locality, State FROM OpenDataSource( 'MSDASQL',
'Driver={Microsoft Text Driver (*.txt; *.csv)};
DefaultDir=C:\;').[C:\]..[PostCodes.csv]
With the following error returned:
OLE DB provider "MSDASQL" for linked server "(null)" returned message
"[Microsof
t][ODBC Text Driver] Syntax error (missing operator) in query expression
'`Tbl10
02`.`Pcode` `Col1004`'.".
Msg 7321, Level 16, State 2, Server DIMENSION9150, Line 1
An error occurred while preparing the query "SELECT `Tbl1002`.`Pcode`
`Col1004`,
`Tbl1002`.`Locality` `Col1005`,`Tbl1002`.`State` `Col1006` FROM
`C:\`\`PostCodes
.csv` `Tbl1002`" for execution against OLE DB provider "MSDASQL" for linked
serv
er "(null)".|||"McHenry" <mchenry@.mchenry.com> wrote in message
news:44462abf$0$16667$5a62ac22@.per-qv1-newsreader-01.iinet.net.au...
> "Omnibuzz" <Omnibuzz@.discussions.microsoft.com> wrote in message
> news:7268C38F-0C91-4D60-9DD8-4F004C2A84DD@.microsoft.com...
> Thanks for the help however I have never doen this before and...
> I've enabled OpenDataSource as required.
> The file name is C:\PostCodes.CSV and has field names in the first row.
> I am interested in the first three columns
> PCode, Locality & State
> So I have tried without success:
> SELECT PCode, Locality, State FROM OpenDataSource( 'MSDASQL',
> 'Driver={Microsoft Text Driver (*.txt; *.csv)};
> DefaultDir=C:\;').[C:\]..[PostCodes.csv]
> With the following error returned:
> OLE DB provider "MSDASQL" for linked server "(null)" returned message
> "[Microsof
> t][ODBC Text Driver] Syntax error (missing operator) in query expression
> '`Tbl10
> 02`.`Pcode` `Col1004`'.".
> Msg 7321, Level 16, State 2, Server DIMENSION9150, Line 1
> An error occurred while preparing the query "SELECT `Tbl1002`.`Pcode`
> `Col1004`,
> `Tbl1002`.`Locality` `Col1005`,`Tbl1002`.`State` `Col1006` FROM
> `C:\`\`PostCodes
> .csv` `Tbl1002`" for execution against OLE DB provider "MSDASQL" for
> linked serv
> er "(null)".
>
Fixed and thanks for the help...
select * from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt;
*.csv)};
DefaultDir=C:\;','select * from PostCodes.csv')
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment