Re: Export data to CSV in SQL Server
- From: Martin Gregorie <martin@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 2 Mar 2010 12:50:48 +0000 (UTC)
On Mon, 01 Mar 2010 19:36:06 -0500, Arne Vajhøj wrote:
On 01-03-2010 17:07, Martin Gregorie wrote:I'm surprised the OP's code even compiled unless '"+filename+'" was a
On Mon, 01 Mar 2010 13:18:01 -0800, olegkon wrote:
I am trying to write a Java JDBC program exporting data from theObvious: your single and double quotes are mismatched.
database into CSV file using SQL Server 2005 DB.
From that query:
String="SELECT * into OUTFILE '"+filename+'" FIELDS TERMINATED BY ','
FROM table1";
getting: "SQLException: Incorrect syntax near 'myfilename.csv'
Yes, I put filename in single quotes. Same problem without them, but
it strips out csv file extension.
Use '"+filename+"' instead of '"+filename+'"
I don't think he would get an SQLException if his code really had that
problem.
typo. My rearrangement would at least compile correctly. I don't know SQL
Server well enough to know whether it would like the 'into outfile'
syntax. Postgres doesn't.
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
.
- Follow-Ups:
- Re: Export data to CSV in SQL Server
- From: Arne Vajhøj
- Re: Export data to CSV in SQL Server
- From: Lew
- Re: Export data to CSV in SQL Server
- References:
- Export data to CSV in SQL Server
- From: olegkon
- Re: Export data to CSV in SQL Server
- From: Martin Gregorie
- Re: Export data to CSV in SQL Server
- From: Arne Vajhøj
- Export data to CSV in SQL Server
- Prev by Date: Re: Export data to CSV in SQL Server
- Next by Date: Re: Export data to CSV in SQL Server
- Previous by thread: Re: Export data to CSV in SQL Server
- Next by thread: Re: Export data to CSV in SQL Server
- Index(es):
Relevant Pages
|