从命令提示符将spool输出到特定文件 [英] spool output to particular file from command prompt

查看:242
本文介绍了从命令提示符将spool输出到特定文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

>

将我的输出缓存到特定文件。
我的数据库在SqlServer。我在命令提示符中输入代码如下:

I want to spool my output to a particular file. My database in SqlServer. I am entering code in command prompt like this:

首先,我要像这样连接到我的数据库:

First I am connecting to my data base like this:

sqlcmd -S SUPPORT2/SUPPORT2 -U sa -P solutions

SUPPORT2 / SUPPORT2是我的服务器名称。

我选择我的数据库名称(vallett),然后我从EmployeeMaster_tbl中选择Ename。

我想将此输出假脱机到特定的字文件,如何我这样做?

SUPPORT2/SUPPORT2 is a my server name.
I choose my database name(vallett), then I am selecting Ename from EmployeeMaster_tbl.
I want to spool this output to a particular word file, how can I do this?

我尝试过这样的东西,但得到一个错误

I tried somthing like this..but getting an error

推荐答案

-o 是sqlcmd调用的参数

-o is a parameter for the call of sqlcmd a call could look like this

sqlcmd -S SUPPORT2/SUPPORT2 -U sa -P solutions -Q " SELECT Ename from Vallett.dbo.EmployeeMaster_tbl" -o C:\temp\test.txt 

使目标文件可写(C:\txt1.txt可能不可用)

Make shure the destination file can be written (C:\txt1.txt might not be possible)

您想要创建交互式输出文件,可以使用:OUT 将输出重定向到文件,并将ist重置为 stdout 。示例可能如下所示:

If you want to create the output file interactive you can use :OUT to redirect the output to a file and reset ist to stdout. An example could look like this:

 sqlcmd -S SUPPORT2/SUPPORT2 -U sa -P solutions 
 use Vallett
 GO
 :OUT C:\temp\test.txt
 SELECT Ename from dbo.EmployeeMaster_tbl
 GO
 :OUT stdout

这篇关于从命令提示符将spool输出到特定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆