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. General Programming
  3. C#
  4. How to Import data from excel to sql server 2005

How to Import data from excel to sql server 2005

Scheduled Pinned Locked Moved C#
csharpdatabasesql-serversysadminhelp
7 Posts 5 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.
  • R Offline
    R Offline
    rahul honey
    wrote on last edited by
    #1

    I want to import data from excel to sql server 2005. I am using C# for this purpose. I successfully exported the data of general format to varchar. But, the problem arises while exporting the data of date type. I have used date format in excel and want to export it in sql server 2005's datetime field. The code that I have used is:- SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection); sqlBulk.DestinationTableName = "Data_Master_Inventory"; sqlBulk.ColumnMappings.Add("VendorRegistrationNo", "VendorRegistrationNo"); sqlBulk.ColumnMappings.Add("ProductCode", "ProductCode"); sqlBulk.ColumnMappings.Add("SerialNo", "SerialNo"); sqlBulk.ColumnMappings.Add("VendorProvidedSerialNo", "VendorProvidedSerialNo"); sqlBulk.ColumnMappings.Add("ModelName", "ModelName"); sqlBulk.ColumnMappings.Add("ProductCategoryCode", "ProductCategoryCode"); sqlBulk.ColumnMappings.Add("InventoryDate", "InventoryDate"); sqlBulk.WriteToServer(dReader); Please provide me necessary solution.

    R R 2 Replies Last reply
    0
    • R rahul honey

      I want to import data from excel to sql server 2005. I am using C# for this purpose. I successfully exported the data of general format to varchar. But, the problem arises while exporting the data of date type. I have used date format in excel and want to export it in sql server 2005's datetime field. The code that I have used is:- SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection); sqlBulk.DestinationTableName = "Data_Master_Inventory"; sqlBulk.ColumnMappings.Add("VendorRegistrationNo", "VendorRegistrationNo"); sqlBulk.ColumnMappings.Add("ProductCode", "ProductCode"); sqlBulk.ColumnMappings.Add("SerialNo", "SerialNo"); sqlBulk.ColumnMappings.Add("VendorProvidedSerialNo", "VendorProvidedSerialNo"); sqlBulk.ColumnMappings.Add("ModelName", "ModelName"); sqlBulk.ColumnMappings.Add("ProductCategoryCode", "ProductCategoryCode"); sqlBulk.ColumnMappings.Add("InventoryDate", "InventoryDate"); sqlBulk.WriteToServer(dReader); Please provide me necessary solution.

      R Offline
      R Offline
      RavinderaG
      wrote on last edited by
      #2

      Hi Rahul U can refer these links http://www.sqlteam.com/article/use-sqlbulkcopy-to-quickly-load-data-from-your-client-to-sql-server http://www.codeproject.com/KB/database/SqlBulkCopy.aspx http://www.codeproject.com/KB/database/TransferUsingSQLBulkCopy.aspx http://stackoverflow.com/questions/2238328/sqlbulkcopy-writetoserver-example-what-am-i-doing-wrong Thanks Ravindra

      L R 2 Replies Last reply
      0
      • R RavinderaG

        Hi Rahul U can refer these links http://www.sqlteam.com/article/use-sqlbulkcopy-to-quickly-load-data-from-your-client-to-sql-server http://www.codeproject.com/KB/database/SqlBulkCopy.aspx http://www.codeproject.com/KB/database/TransferUsingSQLBulkCopy.aspx http://stackoverflow.com/questions/2238328/sqlbulkcopy-writetoserver-example-what-am-i-doing-wrong Thanks Ravindra

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

        Please use the appropriate editor buttons to make your links clickable.

        Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

        realJSOPR 1 Reply Last reply
        0
        • L Lost User

          Please use the appropriate editor buttons to make your links clickable.

          Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

          realJSOPR Offline
          realJSOPR Offline
          realJSOP
          wrote on last edited by
          #4

          It's gonna be one of those kinds of days...

          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
          -----
          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
          -----
          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

          L 1 Reply Last reply
          0
          • realJSOPR realJSOP

            It's gonna be one of those kinds of days...

            ".45 ACP - because shooting twice is just silly" - JSOP, 2010
            -----
            You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
            -----
            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

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

            No change there then. ;)

            Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

            1 Reply Last reply
            0
            • R rahul honey

              I want to import data from excel to sql server 2005. I am using C# for this purpose. I successfully exported the data of general format to varchar. But, the problem arises while exporting the data of date type. I have used date format in excel and want to export it in sql server 2005's datetime field. The code that I have used is:- SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection); sqlBulk.DestinationTableName = "Data_Master_Inventory"; sqlBulk.ColumnMappings.Add("VendorRegistrationNo", "VendorRegistrationNo"); sqlBulk.ColumnMappings.Add("ProductCode", "ProductCode"); sqlBulk.ColumnMappings.Add("SerialNo", "SerialNo"); sqlBulk.ColumnMappings.Add("VendorProvidedSerialNo", "VendorProvidedSerialNo"); sqlBulk.ColumnMappings.Add("ModelName", "ModelName"); sqlBulk.ColumnMappings.Add("ProductCategoryCode", "ProductCategoryCode"); sqlBulk.ColumnMappings.Add("InventoryDate", "InventoryDate"); sqlBulk.WriteToServer(dReader); Please provide me necessary solution.

              R Offline
              R Offline
              RaviRanjanKr
              wrote on last edited by
              #6

              Always wrap your code in "pre" tag.

              1 Reply Last reply
              0
              • R RavinderaG

                Hi Rahul U can refer these links http://www.sqlteam.com/article/use-sqlbulkcopy-to-quickly-load-data-from-your-client-to-sql-server http://www.codeproject.com/KB/database/SqlBulkCopy.aspx http://www.codeproject.com/KB/database/TransferUsingSQLBulkCopy.aspx http://stackoverflow.com/questions/2238328/sqlbulkcopy-writetoserver-example-what-am-i-doing-wrong Thanks Ravindra

                R Offline
                R Offline
                RaviRanjanKr
                wrote on last edited by
                #7

                hey! Please convert Url to Hyperlink! because it provide better readability and accessibility to other user.

                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