I want error log file when I do bulk insert. My sample code is :
But I want to add some hard_coded field other than the fields included in the file. So I need to use with openrowset. Do you have any idea with second method to add some more fields, or any advise of what is wrong with first method? Thank you.
Code:
INSERT INTO tbl_test( USER_ID, CODE, EXCHANGE, UPDATED_DATE) SELECT LTRIM(RTRIM(USER_ID)), LTRIM(RTRIM(CODE)), EXCHANGE = '11', UPDATED_DATE = getdate() FROM OPENROWSET( BULK N'c:\test.txt', FORMATFILE='c:\test.fmt.txt', ERRORFILE = 'c:\ERROR.txt') A But the error log is not appeared in this way. What's wrong with this code? When I tried like below, it's work well. BULK INSERT tbl_test FROM 'c:\test.txt' WITH ( FIELDTERMINATOR='|', ROWTERMINATOR = '\n', FORMATFILE='c:\test.fmt.txt', ERRORFILE = 'c:\ERROR.txt'
Comment