Use the replicate function with the len function.

Something like below where 10 is the field size needed..


select personid + REPLICATE(' ', 10-len(personid) ),



Kore Peterson





                                                                                                           
                    "Eric Creese"                                                                          
                    <[EMAIL PROTECTED]       To:     CF-Talk <[EMAIL PROTECTED]>                       
                    rg>                  cc:                                                               
                                         Subject:     OT: SQL padding then to file question               
                    09/29/2003                                                                             
                    02:41 PM                                                                              
                    Please respond                                                                        
                    to cf-talk                                                                             
                                                                                                           
                                                                                                           




I have been given a task to get some data and put it into a file format for
another company with starting and end positions for each column. For
example this file requires the following

name                 width          start           end
unique id       10        1         10
Indicator       1         11        11
title                     4         12         15
first name           30        16         45
mid initial          1         46         46
last name       35        47        81

...and so on.

Here is my query

select personid,companyid
='I',perprefix,perfname,left(permname,1),perlname,addrline1+' '
+addrline2,city,state,left(zip,5),country = 'USA'
from peopleroleup
where country ='United States'
and companyid  is null

How do I pad this out? I am using SQL2k Query Analyzer.



[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to