Prev: Fill leading zeros
Next: SELECT Query Help
From: Jonathan on 26 Apr 2010 18:48 Hi, is there a switch that I can use so that the first row of the destination text file contains the exported view column names? Any ideas appreciated :-) Many thanks, Jonathan
From: Erland Sommarskog on 27 Apr 2010 03:20 Jonathan (Jonathan(a)discussions.microsoft.com) writes: > Hi, is there a switch that I can use so that the first row of the > destination text file contains the exported view column names? No, there isn't. You can compose a UNION ALL query that includes the colunm names, but it can be difficult to ensure that the column names come first. A better solution may be to write a separate file with the column names, and then use COPY command to append the two files. But this is not viable if the exported file is huge. -- Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
From: Jonathan on 27 Apr 2010 17:07 Thanks Erland. I had a feeling that this was the case and have used the method as you described as a work around. Jonathan "Erland Sommarskog" wrote: > Jonathan (Jonathan(a)discussions.microsoft.com) writes: > > Hi, is there a switch that I can use so that the first row of the > > destination text file contains the exported view column names? > > No, there isn't. You can compose a UNION ALL query that includes the > colunm names, but it can be difficult to ensure that the column names > come first. A better solution may be to write a separate file with the > column names, and then use COPY command to append the two files. But > this is not viable if the exported file is huge. > > -- > Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se > > Books Online for SQL Server 2005 at > http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx > Books Online for SQL Server 2000 at > http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx > . >
From: Michael Coles on 28 Apr 2010 22:10 You might also take a look at SQLCMD (http://msdn.microsoft.com/en-us/library/ms162773.aspx). You can execute a query in SQLCMD and redirect the output to a file, and get headers in the output. -- Thanks Michael Coles SQL Server MVP Author, "Expert SQL Server 2008 Encryption" (http://www.apress.com/book/view/1430224649) ---------------- "Jonathan" <Jonathan(a)discussions.microsoft.com> wrote in message news:14F15654-B255-44E4-B720-ED592725D44D(a)microsoft.com... > Thanks Erland. I had a feeling that this was the case and have used the > method as you described as a work around. > > Jonathan > > "Erland Sommarskog" wrote: > >> Jonathan (Jonathan(a)discussions.microsoft.com) writes: >> > Hi, is there a switch that I can use so that the first row of the >> > destination text file contains the exported view column names? >> >> No, there isn't. You can compose a UNION ALL query that includes the >> colunm names, but it can be difficult to ensure that the column names >> come first. A better solution may be to write a separate file with the >> column names, and then use COPY command to append the two files. But >> this is not viable if the exported file is huge. >> >> -- >> Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se >> >> Books Online for SQL Server 2005 at >> http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx >> Books Online for SQL Server 2000 at >> http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx >> . >>
|
Pages: 1 Prev: Fill leading zeros Next: SELECT Query Help |