[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference amcucs::ms-sqlsvr

Title:Microsoft SQL Server Support
Notice:Please Registar, Note #11
Moderator:AMCUCS::BETTS
Created:Tue Aug 23 1994
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:382
Total number of notes:1233

339.0. "BCP format file assistance needed" by STKHLM::KNORN (I'm still here) Tue Feb 18 1997 04:24

    
    
    	I have a data file with 16 fields and a database table with 22
    	fields. I'm trying to load the data file into the table with BCP
    	but I can't get it to work.
    
    	Reading the documentation (Administrators companion) doesn't help
    	a lot. I'll make a short example and hope someone can help me out.
    	(for the sake of the example lets assume 4 fields in data file and
    	8 in database table).
    
    	Data file
    	field1,field3,field2,field4
    
    	Database table
    	field1
    	field2
    	field3
    	FIELD_A
    	FIELD_B
    	FIELD_C
    	FIELD_D
    	field4
    
    	The the default format file would look like 
    
    6.0
    8
    1       SQLCHAR       0       14      ","         1       field1
    2       SQLCHAR       0       25      ","         2       field2
    3       SQLCHAR       0       4       ","         3       field3
    4       SQLCHAR       0       15      ","         4       FIELD_A
    5       SQLCHAR       0       8       ","         5       FIELD_B
    6       SQLCHAR       0       25      ","         6       FIELD_C
    7       SQLCHAR       0       4       ","         7       FIELD_D
    8	    SQLCHAR	  0       7       "\n\r"      8       field_4
    
    
    How should the correct format file look like ?
    
    Stefan Knorn
    NSIS Stockholm
T.RTitleUserPersonal
Name
DateLines
339.1The answer is ...STKHLM::KNORNI'm still hereWed Feb 26 1997 07:1011
    
    6.0
    4
    1       SQLCHAR       0       14      ","         1       field1
    2       SQLCHAR       0       25      ","         2       field2
    3       SQLCHAR       0       4       ","         3       field3
    4	    SQLCHAR	  0       7       "\n\r"      8       field_4
    
    Important that the first column is the field number in the data file,
    which the doc's don't clarify a lot.
    
339.2CSC32::HOEPNERA closed mouth gathers no feetWed Feb 26 1997 12:143
    
    Thanks for the update.