Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 18,678 of 19,505    |
|    Erland Sommarskog to Cathy    |
|    Re: MSSMSE - Export results to CSV    |
|    21 Jun 12 23:40:39    |
      From: esquel@sommarskog.se              Cathy (Cathy@Nospam.com) writes:       > I have tried saving the script and running it with osql       > (sorry should have mentioned earlier this is still an old SQL2000 server)       > But unfortunately the resultant CSV file seems to have a lot of blank       > spaces and wraps lines and just is not in the same CSV format as that       > exported in first step.       >       > I am therefore wondering if there is not a way in which I could add       > something into the SELECT statement to save reults to CSV file and hope       > the results come out in the same format,              You can use -h option to supress headers, -s to set the column separator and       -w to control the width of the output. However, there will still be a lot of       space.              However, a better option for you may be BCP, at least as long as you       don't want the header lines.              bcp "yourquerygoeshere" queryout outputfile.txt -c -t, -CRAW -T -S server              -T is for trusted connection. Use -U and -P if you use SQL Server       authentication.              Beware that if there is comma in the data, bcp will not quote the value.                     --       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              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca