Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print command does strange things 1

Status
Not open for further replies.

puredesi5

Programmer
Sep 26, 2001
50
US
I am using MS SQL 6.5.
There is a .bat file on server, it calls a stored procedure.
The stored procedure selects few fields from a table. (select a, b, c from tbl1).
It also calculates few fields. select d = a + 1, e = ......
I haven't described all the fields, but you get the picture.
It writes selected, and calculated fields to a text file using 'PRINT' command (selet @msg = format(a) + '<' format (b) + '<' ....)
BTW, ('<' is used as field separator in BCP)
Then it issues print command (PRINT @msg)

The problem is, print command puts all fields on one line most of the times. However, sometimes, it puts all fields on two lines, few fields on line 1, and rest on line 2.

Then, .bat file takes the text file and loads it on to a second table using BCP.

When BCP finds one record splited into two lines, sometimes, it doesn't handle some date fields right.

Does anyone know how we can make print command write all fields on one line. It does right most of the times, but not all the time.

I will appreciate the help.
 
I assume you use ISQL or OSQL in the .BAT file to execute the stored procedure. If so add the -w option to the OSQL command line. -w 256 would allow output of a line 256 characters wide. The default width is 80 characters.

If you are not using these utilities, please explain how you are executing the SP. Terry L. Broadbent
Programming and Computing Resources
 
tlbroadbent, Thank you so much. Yes, I am using ISQL. I added -w 256 and it worked.

What's odd is..same .bat file (without -w parameter) is called by another process and it works. I am assuming it takes default (of output file) of that automatic process.

I was executing my .bat file from DOS window, which obviously has default of 80 characters for screen.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top