Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 21 Jun 2012 13:24:14 -0500 From: "Cathy" Newsgroups: comp.databases.ms-sqlserver Subject: MSSMSE - Export results to CSV Date: Thu, 21 Jun 2012 19:24:11 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6002.18197 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18463 Message-ID: <5oudnZwNaMRT-37SnZ2dnUVZ8g-dnZ2d@bt.com> Lines: 30 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-Bffsy5antPNrHQarCkquvpCHGVa/6UXYY8cYzhj23llfNlFqVDulgPqtB1wRgX7NJfGyMHKyVF7WhU2!aqb0aZ2e2QI5Yc7OLtaT8vvuNy0MBwQR0cGudWTNHyU0vZIJN1ie6gIiLxKora6QcoaEQmXOJXk= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2331 Xref: csiph.com comp.databases.ms-sqlserver:1139 I regularly run a complex script manually in MSSMSE. The results shown in Grid I then right click on the top left corner of the grid and select "Save results as" and then save it as a CSV file. The above works just as I want it to and the saved CSV file is just as I would expect to see it. But I have to do this for a large number of queries on all databases on the server which is very time consuming. 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, I have also tried altering settings to save results to file instead of GRID but this also comes out in a different format. If anybody has tried to do this before and come accross a solution for this I will really appreciate it. Regards C