Friday, March 30, 2012

output 2 table data to a text file

hi, how to output 2 table data to a text file?Not specifing what you want...
You can use bcp, osql with the -o switch or if you just wanna put out the
result of a query in QA you can send the result to a fiel rather than to the
result pane.
Is it that what you need ?
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"js" <js@.someone@.hotmail.com> schrieb im Newsbeitrag
news:uCTvwdPTFHA.632@.TK2MSFTNGP10.phx.gbl...
> hi, how to output 2 table data to a text file?
>|||can I do it in a query: select * from tb1 output my.txt?
"Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> wrote in
message news:OoINvkPTFHA.1148@.tk2msftngp13.phx.gbl...
> Not specifing what you want...
> You can use bcp, osql with the -o switch or if you just wanna put out the
> result of a query in QA you can send the result to a fiel rather than to
> the result pane.
> Is it that what you need ?
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
>
> "js" <js@.someone@.hotmail.com> schrieb im Newsbeitrag
> news:uCTvwdPTFHA.632@.TK2MSFTNGP10.phx.gbl...
>|||Yes of course, here is an example:
osql -E -Q"Select TOP 1 * from Northwind..Orders" -o "C:\Output.txt"
will produuce the following output:
OrderID CustomerID EmployeeID OrderDate
RequiredDate ShippedDate ShipVia
Freight ShipName
ShipAddress
ShipCity ShipRegion ShipPostalCode ShipCountry
-- -- -- --
-- -- --
-- ---
----
-- -- -- --
10248 VINET 5 1996-07-04 00:00:00.000
1996-08-01 00:00:00.000 1996-07-16 00:00:00.000 3
32.3800 Vins et als Chevalier
59 rue de l'Abbaye
Reims NULL 51100 France
(1 row affected)
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"js" <js@.someone@.hotmail.com> schrieb im Newsbeitrag
news:uoTJioPTFHA.2336@.TK2MSFTNGP12.phx.gbl...
> can I do it in a query: select * from tb1 output my.txt?
> "Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> wrote
> in message news:OoINvkPTFHA.1148@.tk2msftngp13.phx.gbl...
>|||Thanks Jens...|||how about this:
osql -E -Q"backup Northwind to disk='c:\output1.txt " -o "C:\Output2.txt" -S
myServer
'c:\output1.txt : Server Path
'C:\Output2.txt : Local Path
can I run it in another worksation? and want to 'c:\output1.txt' located in
the workdation?
"Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> wrote in
message news:eEF4GuPTFHA.3392@.TK2MSFTNGP12.phx.gbl...
> Yes of course, here is an example:
> osql -E -Q"Select TOP 1 * from Northwind..Orders" -o "C:\Output.txt"
> will produuce the following output:
> OrderID CustomerID EmployeeID OrderDate
> RequiredDate ShippedDate ShipVia
> Freight ShipName
> ShipAddress
> ShipCity ShipRegion ShipPostalCode ShipCountry
> -- -- -- --
> -- -- --
> -- ---
> ----
> -- -- -- --
> 10248 VINET 5 1996-07-04 00:00:00.000
> 1996-08-01 00:00:00.000 1996-07-16 00:00:00.000 3
> 32.3800 Vins et als Chevalier
> 59 rue de l'Abbaye
> Reims NULL 51100 France
> (1 row affected)
>
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "js" <js@.someone@.hotmail.com> schrieb im Newsbeitrag
> news:uoTJioPTFHA.2336@.TK2MSFTNGP12.phx.gbl...
>|||Output will be redirected to the workstation due to the output of osql,
backup will be made to the server.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"js" <js@.someone@.hotmail.com> schrieb im Newsbeitrag
news:eOlPq3PTFHA.228@.TK2MSFTNGP12.phx.gbl...
> how about this:
> osql -E -Q"backup Northwind to disk='c:\output1.txt " -o
> "C:\Output2.txt" -S myServer
> 'c:\output1.txt : Server Path
> 'C:\Output2.txt : Local Path
> can I run it in another worksation? and want to 'c:\output1.txt' located
> in the workdation?
>
> "Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> wrote
> in message news:eEF4GuPTFHA.3392@.TK2MSFTNGP12.phx.gbl...
>|||can backup to disk=unc format?
"Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> wrote in
message news:uGRII%23PTFHA.1152@.tk2msftngp13.phx.gbl...
> Output will be redirected to the workstation due to the output of osql,
> backup will be made to the server.
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "js" <js@.someone@.hotmail.com> schrieb im Newsbeitrag
> news:eOlPq3PTFHA.228@.TK2MSFTNGP12.phx.gbl...
>|||YEah that works,
Jens Suessmeyer.
"js" <js@.someone@.hotmail.com> schrieb im Newsbeitrag
news:OdHsAJQTFHA.2812@.TK2MSFTNGP09.phx.gbl...
> can backup to disk=unc format?
> "Jens Smeyer" <Jens@.Remove_this_For_Contacting.sqlserver2005.de> wrote
> in message news:uGRII%23PTFHA.1152@.tk2msftngp13.phx.gbl...
>

No comments:

Post a Comment