none
Replacement for -n operation of OSQL in SQLCMD

    Question

  • Hi ,

    We are into migration from SQL Server 2000 to SQL Server 2008 R2.

    So I am planning to replace osql commands with sqlcmd

    In one of the job steps, the output of a stored procedure is loaded into an output CSV file where we use the -n operation(removes numbering)

    osql -E -dtest -Q"exec sql_cmd" -o"D:\test\sql_cmd.csv" -s"," -w400 -n -b

    when i execute the above line I get the below error:

     -n is an obsolete operation and is ignored

    Any kind of help is highly appreciated.

     

    Thanks,

    sraja

    Monday, February 06, 2012 11:45 AM

Answers

  • Hi sraja,

    Unfortunately, sqlcmd doesn't support -n option. In sqlcmd, there are two new options: -W and -k.

    Please refer to:

    -k[ 1 | 2 ] remove[replace] control characters
    Removes all control characters, such as tabs and new line characters from the output. This preserves column formatting when data is returned. If 1 is specified, the control characters are replaced by a single space. If 2 is specified, consecutive control characters are replaced by a single space.

    -W remove trailing spaces
    This option removes trailing spaces from a column. Use this option together with the -s option when preparing data that is to be exported to another application. Cannot be used with the -y or -Y options.


    Best Regards,
    Iric
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, February 07, 2012 10:08 AM

All replies

  • SQLCMD not support -n option also this option not even support OSQL from SQL 2005
    http://uk.linkedin.com/in/ramjaddu
    Monday, February 06, 2012 12:54 PM
  • Hi Ram,

    Thanks for your reply. Is there any workaround to implement this option in SQLCMD?

    Thanks.

    Tuesday, February 07, 2012 6:03 AM
  • Hi sraja,

    Unfortunately, sqlcmd doesn't support -n option. In sqlcmd, there are two new options: -W and -k.

    Please refer to:

    -k[ 1 | 2 ] remove[replace] control characters
    Removes all control characters, such as tabs and new line characters from the output. This preserves column formatting when data is returned. If 1 is specified, the control characters are replaced by a single space. If 2 is specified, consecutive control characters are replaced by a single space.

    -W remove trailing spaces
    This option removes trailing spaces from a column. Use this option together with the -s option when preparing data that is to be exported to another application. Cannot be used with the -y or -Y options.


    Best Regards,
    Iric
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, February 07, 2012 10:08 AM