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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save results positional

Status
Not open for further replies.

crystal2770

Technical User
Jan 8, 2008
13
US
Hi,

How can I export my query results so that if field one is 5 char and field 2 is 5 chars, they maintain their positions.. meaning.

1111122222

Currently when I export Im getting a space or comma between
11111 22222 so the system that needs to import the file can not do so without manual manipulation..

Thanks
 
What is the query you are using to build the export?


"NOTHING is more important in a database than integrity." ESquared
 
Im setting the positions in my selection..
But its the exporting that Im having trouble with..
Sorry if this looks 'sloppy', im not professional sql

SELECT
substring('DEM3',1,4) as '1',
substring('006',1,3) as '2',
' ' as '3',
substring(rtrim(b.lst_nm)+', '+b.fst_nm,1,32) as '4',
substring(a.med_rec_no,1,9) as '5',
substring(replace(convert(varchar(10),adm_ts,110),'-',''),1,8) as '6',
substring(replace(convert(varchar(10),dschrg_ts,110),'-',''),1,8) as '7',
' ' as '8',
' ' as '9',
substring(replace(convert(varchar(10),b.bth_ts,110),'-',''),1,8) as '10',
substring(h.cod_dtl_ds,1,1) as '11',
substring(convert(varchar(3),datediff(yy,b.bth_ts,getdate())),1,3) as '12',
Right('000000000'+convert(varchar(9),b.soc_scu_no),9) as '13',
' ' as '14',
LEFT( '00000'+ a.vst_ext_id,15) as '15',
' ' as '16',
' ' as '17',
' ' as '18',
' ' as '19',
' ' as '20',
substring(rtrim(j.lst_nm)+', '+j.fst_nm,1,38) as '21',
' ' as '22',
' ' as '23',
' ' as '24',
' ' as '25'
 
YOu are not setting the postions in your query you are making each one a separate field. You need to concatenate all those thigns together to make them one field.
Example of concatenation:
Code:
Select left(Field1,1) + right(Field2, 3) as MyConcatenatedField from Table1


"NOTHING is more important in a database than integrity." ESquared
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top