대용량 데이터를 입력할 일 있어서 bulk insert로 입력하였다.

데이터가 많을 경우 아주 유용하게 사용하였다.


하지만 문제는 입력시 자동으로 포맷이 변경되는 경우이다.

예를 들어 ip나 0으로 시작하는 데이터는 자기 마음대로 포맷을 변경하였다.

ex) 0E1 -> 0x0000xxx

그래서 포맷을 지정하기 위해서 Format file을 이용하려고 하는데... 

[Host file datatype]에서 문제가 발행하였다.

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.utility/html/utility/utility86.htm

Storage format에서 numeric 포맷을 SYBNUMERIC로 변경하여 넣으면 바로 에러가 발생한다.


그래서 방법을 찾던 중 다음 것을 발견하였다.

http://msdn.microsoft.com/en-us/library/ms191175.aspx

Using a Non-XML Format File


You can change the order of a column mapping by changing the order value for the column to indicate the position of the corresponding data field.

The following sample non-XML format file presents a format file, myTestOrder.fmt, that maps the fields in myTestOrder-c.txt to the columns of the myTestOrder table. For information about how to create the data file and table, see "Sample Table and Data File," earlier in this topic. The format file uses character data format.

The format file contains the following information:

          9.0
4
1       SQLCHAR       0       100     ","     3     Col3               SQL_Latin1_General_CP1_CI_AS
2       SQLCHAR       0       100     ","     2     Col2               SQL_Latin1_General_CP1_CI_AS
3       SQLCHAR       0       7       ","     1     Col1               ""
4       SQLCHAR       0       100     "\r\n"  4     Col4               SQL_Latin1_General_CP1_CI_AS

        

위에 같이 Col1 컬럼이 숫자형인데, SYBNUMERIC을 사용하지 않고, 바로 SQLCHAR을 사용하였다.

그후에 입력하니 바로 성공..ㅡㅡ;;

왜 이러는지는 나도 모름..ㅠㅠ

다음 페이지 예제로 확인 <-- 나중에 잊어 먹지 않기 위해서..



Posted by 노을지기