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. user import

user import

Scheduled Pinned Locked Moved Database
databasequestion
12 Posts 4 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.
  • A Offline
    A Offline
    AndyInUK
    wrote on last edited by
    #1

    Hi, I need to import 1000s of users to the database. And there values need to be added to 6-7 different tables. Doing it manually would be a nightmare. I think i can use Cursor for this sort of stuff but never dealt with it in past. Any suggestions? Thank you .

    L L D 3 Replies Last reply
    0
    • A AndyInUK

      Hi, I need to import 1000s of users to the database. And there values need to be added to 6-7 different tables. Doing it manually would be a nightmare. I think i can use Cursor for this sort of stuff but never dealt with it in past. Any suggestions? Thank you .

      L Offline
      L Offline
      loyal ginger
      wrote on last edited by
      #2

      You can first create a text file containing the user records, if you don't already have one. Then use your database engine's import function to load the text file in to a table in one step. I can't give you the actual command to do this because I don't know what database engine you are using. You said you need to load them into many different tables. You may need to modify the text file a bit to load them into these tables because these tables may have different structures. If an import function is not available for the database engine you are using, you will need to write a small program to insert the records to the tables. Hope that helps.

      A 1 Reply Last reply
      0
      • A AndyInUK

        Hi, I need to import 1000s of users to the database. And there values need to be added to 6-7 different tables. Doing it manually would be a nightmare. I think i can use Cursor for this sort of stuff but never dealt with it in past. Any suggestions? Thank you .

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

        What does 'user' mean here ? Are they database users or your application users (stored in something like Users table) ? And what database do you use ?

        L A 2 Replies Last reply
        0
        • L Lost User

          What does 'user' mean here ? Are they database users or your application users (stored in something like Users table) ? And what database do you use ?

          L Offline
          L Offline
          loyal ginger
          wrote on last edited by
          #4

          Good point! The question did not describe that clearly.

          1 Reply Last reply
          0
          • A AndyInUK

            Hi, I need to import 1000s of users to the database. And there values need to be added to 6-7 different tables. Doing it manually would be a nightmare. I think i can use Cursor for this sort of stuff but never dealt with it in past. Any suggestions? Thank you .

            D Offline
            D Offline
            David Mujica
            wrote on last edited by
            #5

            Check these referencs out ... Logins http://msdn.microsoft.com/en-us/library/ms189751.aspx[^] Users http://msdn.microsoft.com/en-us/library/ms173463.aspx[^]

            A 1 Reply Last reply
            0
            • D David Mujica

              Check these referencs out ... Logins http://msdn.microsoft.com/en-us/library/ms189751.aspx[^] Users http://msdn.microsoft.com/en-us/library/ms173463.aspx[^]

              A Offline
              A Offline
              AndyInUK
              wrote on last edited by
              #6

              Sql server 2008. i have already imported the excel spreadsheet with all the users info to database. Now for instance there are different table for address field, different table for name field , differnt table for email etc. So my question is do i have to use curser so that i can insert the users value from this temp table to all the necessary table. if yes then how or if not then what's the best way ? Thank You. Andyyy Reply·

              1 Reply Last reply
              0
              • L loyal ginger

                You can first create a text file containing the user records, if you don't already have one. Then use your database engine's import function to load the text file in to a table in one step. I can't give you the actual command to do this because I don't know what database engine you are using. You said you need to load them into many different tables. You may need to modify the text file a bit to load them into these tables because these tables may have different structures. If an import function is not available for the database engine you are using, you will need to write a small program to insert the records to the tables. Hope that helps.

                A Offline
                A Offline
                AndyInUK
                wrote on last edited by
                #7

                Sql server 2008. i have already imported the excel spreadsheet with all the users info to database. Now for instance there are different table for address field, different table for name field , differnt table for email etc. So my question is do i have to use curser so that i can insert the users value from this temp table to all the necessary table. if yes then how or if not then what's the best way ? Thank You. Andyyy Reply·

                L 1 Reply Last reply
                0
                • L Lost User

                  What does 'user' mean here ? Are they database users or your application users (stored in something like Users table) ? And what database do you use ?

                  A Offline
                  A Offline
                  AndyInUK
                  wrote on last edited by
                  #8

                  Sql server 2008. i have already imported the excel spreadsheet with all the users info to database. Now for instance there are different table for address field, different table for name field , differnt table for email etc. So my question is do i have to use curser so that i can insert the users value from this temp table to all the necessary table. if yes then how or if not then what's the best way ? Thank You. Andyyy

                  L 1 Reply Last reply
                  0
                  • A AndyInUK

                    Sql server 2008. i have already imported the excel spreadsheet with all the users info to database. Now for instance there are different table for address field, different table for name field , differnt table for email etc. So my question is do i have to use curser so that i can insert the users value from this temp table to all the necessary table. if yes then how or if not then what's the best way ? Thank You. Andyyy Reply·

                    L Offline
                    L Offline
                    loyal ginger
                    wrote on last edited by
                    #9

                    In this case all you need to do is to create these "other tables", and then use "INSERT...SELECT..." query to pull out the necessary fields from the temp table and insert the records to the new tables. You can also create the tables and insert the records in one step by using the "SELECT...INTO..." statement. Good luck!

                    1 Reply Last reply
                    0
                    • A AndyInUK

                      Sql server 2008. i have already imported the excel spreadsheet with all the users info to database. Now for instance there are different table for address field, different table for name field , differnt table for email etc. So my question is do i have to use curser so that i can insert the users value from this temp table to all the necessary table. if yes then how or if not then what's the best way ? Thank You. Andyyy

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

                      If your database is properly designed and normalized, then simple update statements will work, otherwise you may have to use cursors.

                      A 1 Reply Last reply
                      0
                      • L Lost User

                        If your database is properly designed and normalized, then simple update statements will work, otherwise you may have to use cursors.

                        A Offline
                        A Offline
                        AndyInUK
                        wrote on last edited by
                        #11

                        simple update statement works to enter one record by manually writing the details that i need to update but how to go to the next row in the table, get all the details and enter it to specific tables. So i am not interested in this manual process. Looking for something automatic - say cursor ? but not getting how to use that.

                        L 1 Reply Last reply
                        0
                        • A AndyInUK

                          simple update statement works to enter one record by manually writing the details that i need to update but how to go to the next row in the table, get all the details and enter it to specific tables. So i am not interested in this manual process. Looking for something automatic - say cursor ? but not getting how to use that.

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

                          The INSERT and UPDATE statements have a syntax that can be used to update multiple rows in the destination table from values in one or more source tables. The syntax is different for each database. These are examples for SQL Server:

                          INSERT INTO EmployeeMaster (FirstName, LastName, EmpID)
                          SELECT EmpFirstName, EmpLastName, EmpID
                          FROM EmployeeTemp
                          WHERE (...........)

                          UPDATE EmployeeMaster
                          SET EmployeeMaster.FirstName = EmployeeTemp.EmpFirstName,
                          EmployeeMaster.LastName = EmployeeTemp.EmpLastName,
                          EmployeeMaster.EmpID = EmployeeTemp.EmpID
                          FROM EmployeeTemp T INNER JOIN EmployeeMaster M ON T.EmpID = M.EmpID
                          WHERE (...........)

                          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