Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. BULK INSERT problem with SQL Server 2008 DATE format

BULK INSERT problem with SQL Server 2008 DATE format

Scheduled Pinned Locked Moved Database
helpdatabasesql-servercomsysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gawiz
    wrote on last edited by
    #1

    SQL Server 2008 has the new 3-byte DATE format that I would like to use, being as I don't need the extra overhead of storing TIME. I used bcp to generate the following format file from my table definition: "<?xml version="1.0"?> <BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <RECORD>    <FIELD ID="1" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="10" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>    <FIELD ID="2" xsi:type="CharTerm" TERMINATOR="\r\n" MAX_LENGTH="11"/> </RECORD> <ROW>    <COLUMN SOURCE="1" NAME="Symbol" xsi:type="SQLVARYCHAR"/>    <COLUMN SOURCE="2" NAME="myDate" xsi:type="SQLDATE"/> </ROW> </BCPFORMAT>" xsi:type="SQLDATE" is used to define the transformation for the date in my ascii file to the DATE in the table. A snippet from the input file is: AAI     19940101 ACL     19981231 AKA     20091208 BULK INSERT interprets all of these dates to be 1900-01-01, which would be the default value I suppose. But if I change my input file to: AAI     1994-01-01 ACL     1998-12-31 AKA     2009-12-08 BULK INSERT inserts the correct date values into my table. This is peculiar because if I define the table to be SMALLDATETIME instead of DATE and SQLDATETIM4 instead of SQLDATE, then either input file works OK. It wouldn't be such a big issue for me except that I have thousands of files each with thousands of rows and converting them all before importing is going to be time consuming. I think this is a bug in SS2008.   I tried to report it to Microsoft, but to open a support ticket costs $99:confused: 1) Is there a free/simple way to report the bug to Microsoft 2) Is there an updated version of bcp.exe (I can't find one) 3) Is there a workaround that doesn't involve pre-formatting the input Thanks Steve

    L 1 Reply Last reply
    0
    • G Gawiz

      SQL Server 2008 has the new 3-byte DATE format that I would like to use, being as I don't need the extra overhead of storing TIME. I used bcp to generate the following format file from my table definition: "<?xml version="1.0"?> <BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <RECORD>    <FIELD ID="1" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="10" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>    <FIELD ID="2" xsi:type="CharTerm" TERMINATOR="\r\n" MAX_LENGTH="11"/> </RECORD> <ROW>    <COLUMN SOURCE="1" NAME="Symbol" xsi:type="SQLVARYCHAR"/>    <COLUMN SOURCE="2" NAME="myDate" xsi:type="SQLDATE"/> </ROW> </BCPFORMAT>" xsi:type="SQLDATE" is used to define the transformation for the date in my ascii file to the DATE in the table. A snippet from the input file is: AAI     19940101 ACL     19981231 AKA     20091208 BULK INSERT interprets all of these dates to be 1900-01-01, which would be the default value I suppose. But if I change my input file to: AAI     1994-01-01 ACL     1998-12-31 AKA     2009-12-08 BULK INSERT inserts the correct date values into my table. This is peculiar because if I define the table to be SMALLDATETIME instead of DATE and SQLDATETIM4 instead of SQLDATE, then either input file works OK. It wouldn't be such a big issue for me except that I have thousands of files each with thousands of rows and converting them all before importing is going to be time consuming. I think this is a bug in SS2008.   I tried to report it to Microsoft, but to open a support ticket costs $99:confused: 1) Is there a free/simple way to report the bug to Microsoft 2) Is there an updated version of bcp.exe (I can't find one) 3) Is there a workaround that doesn't involve pre-formatting the input Thanks Steve

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Gawiz wrote:

      1. Is there a free/simple way to report the bug to Microsoft

      Microsoft Connect[^]?

      Gawiz wrote:

      1. Is there a workaround that doesn't involve pre-formatting the input

      Converting the results, by importing into the SMALLDATETIME and SQLDATETIM4 types and ALTERing the columntype afterwards.

      I are Troll :suss:

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups