create fmt file
exec master.dbo.xp_cmdshell 'bcp "DATABASE.dbo.TABLE" format null -f C:\FOLDER\FILE.fmt -c -T -U username -S ip
-e C:\FOLDER\err.txt'
ERR.txt - error log file
The upload code is different int sql 2000 and 2005
--2005
select *
FROM OPENROWSET(BULK 'C:\FOLDER\FILE.csv',
FORMATFILE = 'c:\FOLDER\FILE.fmt') as tmp1
--2000
BULK INSERT ABR_FRAMEWORK.dbo.ABR_CRB_ERR_TRANSMISIE FROM 'c:\FILE\FILE.csv'
WITH (FORMATFILE = 'c:\FOLDER\FILE.fmt')
No comments:
Post a Comment