August 1, 2006 at 1:19 pm
If I needed to try to output the results of a query to a file with the following format:
columns trimmed of whitespace and delimited by ; (last column not followed by delimiter)
rows delimited by CRLF
what (besides concatenating and trimming the columns into one large, ;-delimited column manually) and then bcp-ing the results of that query, are my options? Tried osql with the query, but it does not trim the columns, even with rtrim and ltrim (note: some of these columns are variable-length, some are integers, etc.)
-- http://dbachman.blogspot.com
August 1, 2006 at 1:32 pm
Try it with bcp.exe, RTRIMming your fixed length CHAR columns, such as:
bcp "select id, rtrim(name), email_address from test..contacts" queryout contacts.txt -c -t; -T
August 1, 2006 at 2:16 pm
That did it - for some reason I looked at BOL's command options and all I saw were the ones that defaulted the delimiters to spaces. Thank you thank you!
-- http://dbachman.blogspot.com
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply