|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Export the results from a view to a .csv from the command lineI currently have a view setup in SQL2005 and I need the results from
this view exported to a .csv file. (The view draws information from four tables within a single DB) In itself this is easy enough however I need this to be done from the command line.............. Is this possible & if so how do I go about it ?? You can use sqlcmd or bcp to do this (see BOL for syntax) e.g.
sqlcmd -S (local) -E -s, -Q "set nocount on select * from Northwind.dbo.[Alphabetical list of products]" -o c:\view.csv -h-1 -W bcp "select * from Northwind.dbo.[Alphabetical list of products]" queryout c:\viewbcp.csv -S SQL2005 -T -w Show quote "SecAnalyst" <SecAnal***@googlemail.com> wrote in message news:1146037700.594336.310260@u72g2000cwu.googlegroups.com... >I currently have a view setup in SQL2005 and I need the results from > this view exported to a .csv file. (The view draws information from > four tables within a single DB) > > In itself this is easy enough however I need this to be done from the > command line.............. > > Is this possible & if so how do I go about it ?? > Hmmm... Will this give you the data in the csv format?
Linchi Show quote "Jasper Smith" wrote: > You can use sqlcmd or bcp to do this (see BOL for syntax) e.g. > > sqlcmd -S (local) -E -s, -Q "set nocount on select * from > Northwind.dbo.[Alphabetical list of products]" -o c:\view.csv -h-1 -W > > bcp "select * from Northwind.dbo.[Alphabetical list of products]" queryout > c:\viewbcp.csv -S SQL2005 -T -w > > -- > HTH, > Jasper Smith (SQL Server MVP) > http://www.sqldbatips.com > > > "SecAnalyst" <SecAnal***@googlemail.com> wrote in message > news:1146037700.594336.310260@u72g2000cwu.googlegroups.com... > >I currently have a view setup in SQL2005 and I need the results from > > this view exported to a .csv file. (The view draws information from > > four tables within a single DB) > > > > In itself this is easy enough however I need this to be done from the > > command line.............. > > > > Is this possible & if so how do I go about it ?? > > > > > Works for me :-)
Show quote "Linchi Shea" <LinchiS***@discussions.microsoft.com> wrote in message news:35C215FD-1033-47A2-BD61-19EEBE7C66D0@microsoft.com... > Hmmm... Will this give you the data in the csv format? > > Linchi > > "Jasper Smith" wrote: > >> You can use sqlcmd or bcp to do this (see BOL for syntax) e.g. >> >> sqlcmd -S (local) -E -s, -Q "set nocount on select * from >> Northwind.dbo.[Alphabetical list of products]" -o c:\view.csv -h-1 -W >> >> bcp "select * from Northwind.dbo.[Alphabetical list of products]" >> queryout >> c:\viewbcp.csv -S SQL2005 -T -w >> >> -- >> HTH, >> Jasper Smith (SQL Server MVP) >> http://www.sqldbatips.com >> >> >> "SecAnalyst" <SecAnal***@googlemail.com> wrote in message >> news:1146037700.594336.310260@u72g2000cwu.googlegroups.com... >> >I currently have a view setup in SQL2005 and I need the results from >> > this view exported to a .csv file. (The view draws information from >> > four tables within a single DB) >> > >> > In itself this is easy enough however I need this to be done from the >> > command line.............. >> > >> > Is this possible & if so how do I go about it ?? >> > >> >> >> |
|||||||||||||||||||||||