sql server - Efficient way to generate fixed length fields flat file - T-SQL or SSIS package with flat-file as destination -


do think efficient method generate record fixed length fields using t-sql sql server 2012?

insert #record select   right('0000000000' + rtrim(field01), 10)  +right('          ' + rtrim(field02), 10) +right('00000' + rtrim(field03),6) + etc ... +right('0000000000' + rtrim(fieldnn, 10)  sourcetable 

or should use ssis package sourcetable , flat-fileasdestination , mapped , derived fields.

if dataset not big performance perspective doesn't matter if export data t-sql, siss package or whatever. if one-time task you'd better use management studion it. right click database go tasks->export data.... in wizard choose source database , table. choose flat file destination. there can choose format. among options 1 need fixed length. on configure flat file destination step can edit mappings set columns export , length should be.

if dataset large and/or want automate process should consider using bcp utility supports fixed width file formats.

can't solution bad or won't work it's bugs prone me , hard support if gonna on ragular basis.

hope helps!


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -