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
  1. Home
  2. Database & SysAdmin
  3. Database
  4. MS-SQL - Bulk Insert query

MS-SQL - Bulk Insert query

Scheduled Pinned Locked Moved Database
databasequestion
3 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.
  • 2 Offline
    2 Offline
    224917
    wrote on last edited by
    #1

    I have a .csv file with following column:

    Col1,Col2

    And the data table has one extra datetime column:

    Col1,Col2,TimeStamp

    While importing data using BULK INSERT from the CSV, is there a way to specify the value for the TimeStamp column too? (Timestamp would be same for all the newly imported rows)

    Suhredayan

    A 1 Reply Last reply
    0
    • 2 224917

      I have a .csv file with following column:

      Col1,Col2

      And the data table has one extra datetime column:

      Col1,Col2,TimeStamp

      While importing data using BULK INSERT from the CSV, is there a way to specify the value for the TimeStamp column too? (Timestamp would be same for all the newly imported rows)

      Suhredayan

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      How about defining a default value for the column?

      ALTER TABLE dbo.tablename ADD CONSTRAINT
      DF_TimeStamp DEFAULT '20091218' FOR TimeStamp

      Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

      2 1 Reply Last reply
      0
      • A Ashfield

        How about defining a default value for the column?

        ALTER TABLE dbo.tablename ADD CONSTRAINT
        DF_TimeStamp DEFAULT '20091218' FOR TimeStamp

        Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

        2 Offline
        2 Offline
        224917
        wrote on last edited by
        #3

        Ashfield wrote:

        How about defining a default value for the column?

        That may not work since the timestamp is same only per bulk insert. I do have a solution for this, wrap bulk insert inside a stored proc, and update the the timestamp from SP. But this would introduce few additional steps, was wondering if this can be avoided in case if BULK INSERT already has this feature. Thank you, Suhredayan

        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