0

I'm writing script to connect database & execute store procedures, which works fine. But sqlcmd prints extra information message/ invalid characters to command line. Sqlcmd version 13.0.0000.0 Linux is used.

Refer following error message, for tryouts I had created sample script

DATE: 17 Aug 16  TIME: 08:04:02
1> 2> hi
1> 

Sample script,

date '+DATE: %d %h %y  TIME: %H:%M:%S'
sqlcmd $1 -D -U<dbo> -P<password> -S<db> << EOF
print 'hi'
go
EOF

I'm not getting why 1> 2> message gets display. How to avoid information message/invalid characters of sqlcmd?

3
  • 1> is std out and 2> is std err. Maybe you could set nocount on or pipe the results to null? Aug 17, 2016 at 13:32
  • Thanks @RobertGannon, According me set nocount on is use to avoid 'x row affected' messages and this doesn't have impact on 1> 2> error messages.
    – Pravin
    Aug 22, 2016 at 6:19
  • @Robert1> 2> message are not stdout & stderr. These are prompting number used by sqlcmd command prompt, it shows how many sql sentences pending for execution. (after go terminator sentence it will get executed)
    – Pravin
    Aug 22, 2016 at 9:25

1 Answer 1

0

sqlcmd is command line utility & 1> 2> messages are prompt message. To avoid prompt message you have to specify input through input file.

Use -i switch to give input file. e.x. sqlcmd -i input file -D -U<dbo> -P<password> -S<db>.

Additional info, to avoid command line error message you can update flag using -m 0(default)/1. This switch avoid command line error message e.g. database changed message.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .