January 15, 2008 at 7:20 am
Here I go with another looping post...
If for some reason bcp does not do what you're after, you could do something like
declare
@a char(10)
, @b-2 char(255)
, @C char(50)
While ...
Select
@a = varchara
@b-2 = varcharb
@C = varcharc
From mytable where...
Select @a + @b-2 + @C + char(13) + char(10)
VOILA!
Since chars are padded with spaces, you getfixed width linefeed delimited data!
January 15, 2008 at 4:58 pm
Right idea but no need for the loop...
SELECT CAST(varchara AS CHAR(10))
+ CAST(varcharb AS CHAR(255))
+ CAST(varcharc AS CHAR(50))
FROM yourtable
WHERE...
And, yes, you can do it with BCP using a BCP Format file to control the format.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 15, 2008 at 7:51 pm
Thx Jeff, you da man.
January 16, 2008 at 12:27 am
You bet, Jeremy... thanks for the feedback. Just remember... if you have lots of data, BCP with a format file will absolutely scream compared to this concatenation method.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply