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. insert multiple rows..

insert multiple rows..

Scheduled Pinned Locked Moved Database
databasequestion
16 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.
  • T test 09

    Hi all im using SqlServer2005.. I need to insert multiple rows into a existing table(db1) from other database(db2).. There are around 400 rows(15 columns) need to be inserted. Both db are having same tables. how can i do it.. Thanks...

    modified on Wednesday, September 22, 2010 5:34 AM

    G Offline
    G Offline
    Goutam Patra
    wrote on last edited by
    #2

    Which database?

    test-09 wrote:

    other database(db2)

    Database/table?

    T 1 Reply Last reply
    0
    • G Goutam Patra

      Which database?

      test-09 wrote:

      other database(db2)

      Database/table?

      T Offline
      T Offline
      test 09
      wrote on last edited by
      #3

      sqlserver 2005

      test09

      1 Reply Last reply
      0
      • T test 09

        Hi all im using SqlServer2005.. I need to insert multiple rows into a existing table(db1) from other database(db2).. There are around 400 rows(15 columns) need to be inserted. Both db are having same tables. how can i do it.. Thanks...

        modified on Wednesday, September 22, 2010 5:34 AM

        B Offline
        B Offline
        Blue_Boy
        wrote on last edited by
        #4

        insert into table1 (columname1,columnname2) select columnmae1,columname2 from databasename.dbo.table2


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

        T 1 Reply Last reply
        0
        • B Blue_Boy

          insert into table1 (columname1,columnname2) select columnmae1,columname2 from databasename.dbo.table2


          I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

          T Offline
          T Offline
          test 09
          wrote on last edited by
          #5

          For all 400 rows i need to write the statements?? or any other way..

          test09

          B M 2 Replies Last reply
          0
          • T test 09

            For all 400 rows i need to write the statements?? or any other way..

            test09

            B Offline
            B Offline
            Blue_Boy
            wrote on last edited by
            #6

            That is basic query with which you can import records between tables but in select query it depends on your criterias.


            I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

            T 1 Reply Last reply
            0
            • B Blue_Boy

              That is basic query with which you can import records between tables but in select query it depends on your criterias.


              I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

              T Offline
              T Offline
              test 09
              wrote on last edited by
              #7

              I am having the same db with 2 back ups both have different information(table rows) i need to append both..

              test09

              B 1 Reply Last reply
              0
              • T test 09

                I am having the same db with 2 back ups both have different information(table rows) i need to append both..

                test09

                B Offline
                B Offline
                Blue_Boy
                wrote on last edited by
                #8

                Did you try that query? I think you are trying to merge two databases into one, right?


                I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

                T 1 Reply Last reply
                0
                • B Blue_Boy

                  Did you try that query? I think you are trying to merge two databases into one, right?


                  I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

                  T Offline
                  T Offline
                  test 09
                  wrote on last edited by
                  #9

                  yes but i need to merge only one table..

                  test09

                  B 1 Reply Last reply
                  0
                  • T test 09

                    yes but i need to merge only one table..

                    test09

                    B Offline
                    B Offline
                    Blue_Boy
                    wrote on last edited by
                    #10

                    Then use my query and all will be done.


                    I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

                    T 1 Reply Last reply
                    0
                    • B Blue_Boy

                      Then use my query and all will be done.


                      I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

                      T Offline
                      T Offline
                      test 09
                      wrote on last edited by
                      #11

                      using that query can insert single row how do i select all 400 rows.. or else i need to execute that query for each and every row..

                      test09

                      B 1 Reply Last reply
                      0
                      • T test 09

                        using that query can insert single row how do i select all 400 rows.. or else i need to execute that query for each and every row..

                        test09

                        B Offline
                        B Offline
                        Blue_Boy
                        wrote on last edited by
                        #12

                        That query will insert all rows from table, not only one! Better check this http://en.wikipedia.org/wiki/Insert\_(SQL)


                        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

                        M 1 Reply Last reply
                        0
                        • B Blue_Boy

                          That query will insert all rows from table, not only one! Better check this http://en.wikipedia.org/wiki/Insert\_(SQL)


                          I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

                          M Offline
                          M Offline
                          Mycroft Holmes
                          wrote on last edited by
                          #13

                          He's in trouble if he is trying to merge 2 tables, there will be duplicates unless he filters them out.

                          Never underestimate the power of human stupidity RAH

                          B 1 Reply Last reply
                          0
                          • T test 09

                            For all 400 rows i need to write the statements?? or any other way..

                            test09

                            M Offline
                            M Offline
                            Mycroft Holmes
                            wrote on last edited by
                            #14

                            Take the boys query and add a where clause that filters out existing records so you do not get duplicates. You need to identify the primary key (unique data) in both fields that can be used to apply the filter.

                            Never underestimate the power of human stupidity RAH

                            1 Reply Last reply
                            0
                            • M Mycroft Holmes

                              He's in trouble if he is trying to merge 2 tables, there will be duplicates unless he filters them out.

                              Never underestimate the power of human stupidity RAH

                              B Offline
                              B Offline
                              Blue_Boy
                              wrote on last edited by
                              #15

                              I warned him/her too in previos post, thanks for claryfing me :)


                              I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

                              M 1 Reply Last reply
                              0
                              • B Blue_Boy

                                I warned him/her too in previos post, thanks for claryfing me :)


                                I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

                                M Offline
                                M Offline
                                Mycroft Holmes
                                wrote on last edited by
                                #16

                                Actually I think I could have left it a he's in trouble His level of understanding about database needs upgrading

                                Never underestimate the power of human stupidity RAH

                                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