如何从命令行中获取没有破折号字符的OSQL.exe结果?

时间:2010-07-26 21:51:30

标签: sql-server sql-server-2005 osql

有没有办法从命令行发送一个osql查询,返回的结果不包含代表列宽的大字符长字符?

以下是我正在使用的示例代码:

echo.
"%PROGRAMFILES%\Microsoft SQL Server\%SQLVER%\Tools\BINN\osql" -S . -E -Q "SELECT name + ', ' FROM sysdatabases order by name for XML PATH('')"

结果看起来像这样:

 -------------------------------------------------------------------------------------------------------------------------------------------

        ------------------------------------------------------------------------------------------------------------------------------------

        ------------------------------------------------------------------------------------------------------------------------------------

        ------------------------------------------------------------------------------------------------------------------------------------

        ------------------------------------------------------------------------------------------------------------------------------------
 master, model, msdb, openfire, tempdb,

1 个答案:

答案 0 :(得分:3)

使用-h-1 switch来禁止标题:破折号是标题/数据分隔符“line”

同样的开关也可以用于sqlcmd