Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #1154
| From | Erland Sommarskog <esquel@sommarskog.se> |
|---|---|
| Newsgroups | comp.databases.ms-sqlserver |
| Subject | Re: MSSMSE - Export results to CSV |
| Date | 2012-06-23 11:28 +0200 |
| Organization | Erland Sommarskog |
| Message-ID | <XnsA07B74C453D57Yazorman@127.0.0.1> (permalink) |
| References | (2 earlier) <FpednYO2bofgOn7SnZ2dnUVZ8kydnZ2d@bt.com> <XnsA07A7596B3550Yazorman@127.0.0.1> <1JudnbRjP9BoMnnSnZ2dnUVZ8lmdnZ2d@bt.com> <XnsA07AD1FB0B573Yazorman@127.0.0.1> <qcWdnUB-Rv_uennSnZ2dnUVZ7oKdnZ2d@bt.com> |
Cathy (Cathy@Nospam.com) writes: > This is brilliant >> SELECT CategoryID, CategoryName, quotename(Description, '"') >> FROM [Northwind].[dbo].[Categories] > > Only problem I have now is that bcp reads the quote as the end of the > command. Is there a way to escape this? > > bcp "SELECT CategoryID, CategoryName, quotename(Description, '"')FROM > [Northwind].[dbo].[Categories]" queryout outputfile.csv Well, not BCP but the command-line parser. I should have thought about that, sorry. I think that you can use \ to escape the quote: bcp "SELECT CategoryID, CategoryName, quotename(Description, '\"')FROM [Northwind].[dbo].[Categories]" queryout outputfile.csv But it may be simpler to use quotename(Description, char(34)) instead, and evading the problem that way. -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
Back to comp.databases.ms-sqlserver | Previous | Next — Previous in thread | Next in thread | Find similar
MSSMSE - Export results to CSV "Cathy" <Cathy@Nospam.com> - 2012-06-21 19:24 +0100
Re: MSSMSE - Export results to CSV Erland Sommarskog <esquel@sommarskog.se> - 2012-06-21 23:40 +0200
Re: MSSMSE - Export results to CSV "Cathy" <Cathy@Nospam.com> - 2012-06-22 00:00 +0100
Re: MSSMSE - Export results to CSV Erland Sommarskog <esquel@sommarskog.se> - 2012-06-22 11:33 +0200
Re: MSSMSE - Export results to CSV "Cathy" <Cathy@Nospam.com> - 2012-06-22 18:48 +0100
Re: MSSMSE - Export results to CSV Erland Sommarskog <esquel@sommarskog.se> - 2012-06-22 20:38 +0200
Re: MSSMSE - Export results to CSV "Cathy" <Cathy@Nospam.com> - 2012-06-22 22:45 +0100
Re: MSSMSE - Export results to CSV Erland Sommarskog <esquel@sommarskog.se> - 2012-06-23 11:28 +0200
Re: MSSMSE - Export results to CSV "Cathy" <Cathy@Nospam.com> - 2012-06-23 23:49 +0100
csiph-web