October 6, 2010 at 3:01 am
I have inherited a data collection system that generates raw BCP files that are loaded into SQL server 2008. However, I need to modify this to cater for loading into a table that contains a datetime2(3) column.
Does anybody know how this type of data is encoded within a raw BCP file?
February 18, 2011 at 6:30 am
I just discovered the answer...
The Microsft Sql Server/100/Tools/Binn/bcp.exe utility uses the following format when writing out a datetime2 value in native raw format (bcp options -CRAW -n):
If this value is a null then the single byte 0xFF is written out.
Otherwise:
A single byte 0x08 to indicate a datetime2 value
Followed by 5 bytes that represent the number of Ticks (100 nano-seconds) within the time part of the value. These bytes are written out in the order LSB -> MSB.
Followed by 3-bytes that represent the number of days since 01 Jan 0001. Again these bytes are written out in the order LSB -> MSB.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply