Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with. 
    
        
            
                
                    
                        
                            
                                | Author | 
                                
                                 Topic  | 
                             
                            
                                    | 
                                         duhaas 
                                        Constraint Violating Yak Guru 
                                         
                                        
                                        310 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2007-01-03 : 16:22:51
                                            
  | 
                                             
                                            
                                            | I want to export table lets say to a file, and I want the data to follow the data lengths defined by the rows.  For example, I have a table with 4 columns (col1 - 9chars) (col2 - 2chars) (col3 - 4 chars) (col4 - 2 chars)so than col1 takes up position 1-9 in text file, col22 takes up position 10-11, col3 12-15, col4 16-17hope i am explaining this ok. | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     nr 
                                    SQLTeam MVY 
                                     
                                    
                                    12543 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2007-01-03 : 16:30:14
                                          
  | 
                                         
                                        
                                          | seehttp://www.simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/to format the dataselect left(col1 + space(9),9)  + left(col2 + space(2),2) + left(col3 + space(4),4) + left(col4 + space(2),2) from tblso (easier using a sp as in the article butmaster..xp_cmdshell 'bcp "select left(col1 + space(9),9)  + left(col2 + space(2),2) + left(col3 + space(4),4) + left(col4 + space(2),2) from mydb..tbl" queryout c:\tbl.txt -T -c'==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     duhaas 
                                    Constraint Violating Yak Guru 
                                     
                                    
                                    310 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2007-01-03 : 16:33:21
                                          
  | 
                                         
                                        
                                          | Thanks, I appreciate the advice, I think I also just learned that I can just do a simple export dts package to a .txt file and that appears to leave everything in tact with spacing.  Am i wrong?  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     russell 
                                    Pyro-ma-ni-yak 
                                     
                                    
                                    5072 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2007-01-03 : 16:35:28
                                          
  | 
                                         
                                        
                                          | DTS --in text file connection, tick fixed fieldin destination tab of transform data task, choose populate from source, then executein transformations tab, click ok  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |   
     
     
            
              
	     |  
		
			
     
          
		 |