January 26, 2009 at 9:11 am
How can I create a fixed length file using SSMS?
I assume .. i have to select 'result to file' and then probably, 'space-delimited'? but i am not sure...
plz let me know
Thanks!
January 26, 2009 at 2:36 pm
Here's the jist of it.....
DECLARE @myTable TABLE
(val1 CHAR(9)
,val2 CHAR(9)
,val3 CHAR(5)
,val4 CHAR(9))
INSERT @myTable
SELECT '123456789', '1234', '123', '12345678'
UNION ALL
SELECT '12345', '12','12345', '12345'
SELECT *
FROM @myTable
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgJanuary 26, 2009 at 2:36 pm
Presuming that you are going to run the T-SQL statement in SSMS and direct the results to a file. Try this for a fixed row length:
SELECT LEFT(LEFT(SUBSTRING(Entry,1,24) + SPACE(30),30)+ LEFT(SUBSTRING(Description,1,40) + SPACE(60),50),180)
FROM logentries
January 26, 2009 at 2:38 pm
Thanks!
I figured it out.
Using substring & concatenating them did the trick for me.
Thanks to both of you for your inputs..
January 26, 2009 at 6:19 pm
A call to BCP with a format file would probably have a whole lot more performance.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply