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. Visual Basic
  4. Compare the structure for 2 sql server databases

Compare the structure for 2 sql server databases

Scheduled Pinned Locked Moved Visual Basic
databasequestioncsharpsql-server
24 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.
  • D Offline
    D Offline
    dilkonika
    wrote on last edited by
    #1

    Hello ! In vb.net 2013 , SQL server 2008R2 : I have an active database , and a backup database ( .bak) file. I want to compare the structure of these databases , to know if the structure is identical , if not to have a list with differencies Can you give me some steps , how can I do this on Vb.net ? Thank you !

    W S 2 Replies Last reply
    0
    • D dilkonika

      Hello ! In vb.net 2013 , SQL server 2008R2 : I have an active database , and a backup database ( .bak) file. I want to compare the structure of these databases , to know if the structure is identical , if not to have a list with differencies Can you give me some steps , how can I do this on Vb.net ? Thank you !

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      One way is that you restore the backup somewhere and then using VB start going through the objects one by one to spot the differences. In this approach you would use system tables (or views) to gather information about the objects in both databases. Have a look at https://technet.microsoft.com/en-us/library/ms189082(v=sql.105).aspx[^]. Another approach could be to still do the restore somewhere but then utilize the schema comparison tool: https://msdn.microsoft.com/en-us/library/hh272690(v=vs.103).aspx[^]

      D 1 Reply Last reply
      0
      • W Wendelius

        One way is that you restore the backup somewhere and then using VB start going through the objects one by one to spot the differences. In this approach you would use system tables (or views) to gather information about the objects in both databases. Have a look at https://technet.microsoft.com/en-us/library/ms189082(v=sql.105).aspx[^]. Another approach could be to still do the restore somewhere but then utilize the schema comparison tool: https://msdn.microsoft.com/en-us/library/hh272690(v=vs.103).aspx[^]

        D Offline
        D Offline
        dilkonika
        wrote on last edited by
        #3

        Ok , but I want to know if how to do this with code in vb.net.

        T W 2 Replies Last reply
        0
        • D dilkonika

          Ok , but I want to know if how to do this with code in vb.net.

          T Offline
          T Offline
          Tim Carmichael
          wrote on last edited by
          #4

          Mika gave you a direction; he is not going to give you the code. if you show the code you've written and need help on a particular section, someone may help. But, you are expected to provide the code you wrote first.

          S 1 Reply Last reply
          0
          • T Tim Carmichael

            Mika gave you a direction; he is not going to give you the code. if you show the code you've written and need help on a particular section, someone may help. But, you are expected to provide the code you wrote first.

            S Offline
            S Offline
            Sascha Lefevre
            wrote on last edited by
            #5

            Hi Tim, I don't think dilkonika was asking for ready made code here. He/She asked quite a few questions in the last days and didn't show that kind of attitude; instead came up more than once with own code-attempts. Please read his/her reply again - there's a "if how" in there. I think he/she just didn't understand Mika's reply correctly or didn't pay enough attention. I assume you downvoted the reply, maybe you want to reconsider. cheers, Sascha

            T L 2 Replies Last reply
            0
            • D dilkonika

              Hello ! In vb.net 2013 , SQL server 2008R2 : I have an active database , and a backup database ( .bak) file. I want to compare the structure of these databases , to know if the structure is identical , if not to have a list with differencies Can you give me some steps , how can I do this on Vb.net ? Thank you !

              S Offline
              S Offline
              Sascha Lefevre
              wrote on last edited by
              #6

              SQL Server allows you to query the schema of the database; Mika's first link explains that. I recently searched for open-source projects that accomplish this task and the best thing I found is this Codeproject-article: SQL Server Database Comparison Tool[^]. It appears to have some flaws because it didn't find the differences of two database-schemas I compared with it, but it contains all kinds of SQL-queries to query the database-schema which you could use as a starting point for your own solution.

              D 1 Reply Last reply
              0
              • S Sascha Lefevre

                Hi Tim, I don't think dilkonika was asking for ready made code here. He/She asked quite a few questions in the last days and didn't show that kind of attitude; instead came up more than once with own code-attempts. Please read his/her reply again - there's a "if how" in there. I think he/she just didn't understand Mika's reply correctly or didn't pay enough attention. I assume you downvoted the reply, maybe you want to reconsider. cheers, Sascha

                T Offline
                T Offline
                Tim Carmichael
                wrote on last edited by
                #7

                Sascha, replied but did not vote at all. Thanks for the reply; hadn't seen previous posts from the OP.

                S 1 Reply Last reply
                0
                • T Tim Carmichael

                  Sascha, replied but did not vote at all. Thanks for the reply; hadn't seen previous posts from the OP.

                  S Offline
                  S Offline
                  Sascha Lefevre
                  wrote on last edited by
                  #8

                  Alright :)

                  1 Reply Last reply
                  0
                  • S Sascha Lefevre

                    Hi Tim, I don't think dilkonika was asking for ready made code here. He/She asked quite a few questions in the last days and didn't show that kind of attitude; instead came up more than once with own code-attempts. Please read his/her reply again - there's a "if how" in there. I think he/she just didn't understand Mika's reply correctly or didn't pay enough attention. I assume you downvoted the reply, maybe you want to reconsider. cheers, Sascha

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

                    Sascha Lefévre wrote:

                    I assume you downvoted the reply, maybe you want to reconsider.

                    No, I did, and I am not reconsidering.

                    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                    S 1 Reply Last reply
                    0
                    • L Lost User

                      Sascha Lefévre wrote:

                      I assume you downvoted the reply, maybe you want to reconsider.

                      No, I did, and I am not reconsidering.

                      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                      S Offline
                      S Offline
                      Sascha Lefevre
                      wrote on last edited by
                      #10

                      That's your right. Looking at his/her past messages I think it's a misjudgement.

                      L 1 Reply Last reply
                      0
                      • S Sascha Lefevre

                        That's your right. Looking at his/her past messages I think it's a misjudgement.

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

                        It might not be a literal question of "gimme code", but it is a recurring theme[^].

                        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                        S 1 Reply Last reply
                        0
                        • L Lost User

                          It might not be a literal question of "gimme code", but it is a recurring theme[^].

                          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                          S Offline
                          S Offline
                          Sascha Lefevre
                          wrote on last edited by
                          #12

                          I see what you're getting at, Eddy. I wouldn't downvote for that but I won't deny you having a different opinion on that. cheers, Sascha

                          L 1 Reply Last reply
                          0
                          • S Sascha Lefevre

                            I see what you're getting at, Eddy. I wouldn't downvote for that but I won't deny you having a different opinion on that. cheers, Sascha

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

                            Neither would I, but as stated, it is a recurring theme.

                            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                            S 1 Reply Last reply
                            0
                            • L Lost User

                              Neither would I, but as stated, it is a recurring theme.

                              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                              S Offline
                              S Offline
                              Sascha Lefevre
                              wrote on last edited by
                              #14

                              Roger :thumbsup:

                              1 Reply Last reply
                              0
                              • S Sascha Lefevre

                                SQL Server allows you to query the schema of the database; Mika's first link explains that. I recently searched for open-source projects that accomplish this task and the best thing I found is this Codeproject-article: SQL Server Database Comparison Tool[^]. It appears to have some flaws because it didn't find the differences of two database-schemas I compared with it, but it contains all kinds of SQL-queries to query the database-schema which you could use as a starting point for your own solution.

                                D Offline
                                D Offline
                                dilkonika
                                wrote on last edited by
                                #15

                                Sorry friends. You wrote a lot's of replies here . But I'm not asking for someone to write my code. I need only some steps , with words , not with code. thank you !

                                L 2 Replies Last reply
                                0
                                • D dilkonika

                                  Sorry friends. You wrote a lot's of replies here . But I'm not asking for someone to write my code. I need only some steps , with words , not with code. thank you !

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

                                  You really need to read http://www.codeproject.com/Messages/1278601/How-to-get-an-answer-to-your-question.aspx[^], carefully.

                                  1 Reply Last reply
                                  0
                                  • D dilkonika

                                    Sorry friends. You wrote a lot's of replies here . But I'm not asking for someone to write my code. I need only some steps , with words , not with code. thank you !

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

                                    dilkonika wrote:

                                    I need only some steps , with words , not with code.

                                    Then I must have misread. Looked to me like a post that contained the steps got the answer "how to do this with code in vb.net." Get some sleep and try again tomorrow. If any of the steps are too vague, simply ask for more explanation. FWIW, I'd start by Googleing for the SQL-command to use to restore a backup. After that, probably executing that as a NonQuery. Then, Googeling for "sys.objects", or how to get a list of all objects in Sql Server. If you Google hard enough you'll even find a copy of a poster that contains all the relations between those system tables :) Then I'd be making a list of all the objects in DB A, and probably store it in a new database (DB C). Then I'd be making a list of all the objects in DB B, and store that result as a table too. Then all that is left is comparing those two lists, and displaying the difference. I'd probably do that by trying to JOIN those lists, displaying the result in a datagridview.

                                    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                                    D 1 Reply Last reply
                                    0
                                    • L Lost User

                                      dilkonika wrote:

                                      I need only some steps , with words , not with code.

                                      Then I must have misread. Looked to me like a post that contained the steps got the answer "how to do this with code in vb.net." Get some sleep and try again tomorrow. If any of the steps are too vague, simply ask for more explanation. FWIW, I'd start by Googleing for the SQL-command to use to restore a backup. After that, probably executing that as a NonQuery. Then, Googeling for "sys.objects", or how to get a list of all objects in Sql Server. If you Google hard enough you'll even find a copy of a poster that contains all the relations between those system tables :) Then I'd be making a list of all the objects in DB A, and probably store it in a new database (DB C). Then I'd be making a list of all the objects in DB B, and store that result as a table too. Then all that is left is comparing those two lists, and displaying the difference. I'd probably do that by trying to JOIN those lists, displaying the result in a datagridview.

                                      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                                      D Offline
                                      D Offline
                                      dilkonika
                                      wrote on last edited by
                                      #18

                                      sorry , but in my opinion you should not respond with " Googleing". If all the things are clear in google , then why you keep open this forum ?

                                      L 1 Reply Last reply
                                      0
                                      • D dilkonika

                                        sorry , but in my opinion you should not respond with " Googleing". If all the things are clear in google , then why you keep open this forum ?

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

                                        dilkonika wrote:

                                        If all the things are clear in google

                                        Google is not "documentation", it is a search-machine. You can easily look up what the command is, or you buy a book with all the commands and go through the pages to find all switches.

                                        dilkonika wrote:

                                        then why you keep open this forum ?

                                        I don't! I'm just someone who signed up here and became a member, just like you! There's no employees here that are paid to get you your answers, there's only passers-by that might just be friendly enough to help. If you want to know why, well, go ahead and read about it in the help-section. I'll gladly help with any question. Some basic pointers if required to get started, specific help with errors, I can do. Finding alternative solutions, sure. ..but you will have to write your own code, that is not our job :)

                                        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                                        D 1 Reply Last reply
                                        0
                                        • L Lost User

                                          dilkonika wrote:

                                          If all the things are clear in google

                                          Google is not "documentation", it is a search-machine. You can easily look up what the command is, or you buy a book with all the commands and go through the pages to find all switches.

                                          dilkonika wrote:

                                          then why you keep open this forum ?

                                          I don't! I'm just someone who signed up here and became a member, just like you! There's no employees here that are paid to get you your answers, there's only passers-by that might just be friendly enough to help. If you want to know why, well, go ahead and read about it in the help-section. I'll gladly help with any question. Some basic pointers if required to get started, specific help with errors, I can do. Finding alternative solutions, sure. ..but you will have to write your own code, that is not our job :)

                                          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

                                          D Offline
                                          D Offline
                                          dilkonika
                                          wrote on last edited by
                                          #20

                                          And who ask to you to write my code ? I ask for steps. And a step is not " Go to goolge and search about this ....." when I know the steps , I have provided my code and asked for help. For example look at one of my recent question : http://www.codeproject.com/Messages/5036045/Make-all-the-controls-inside-a-Groupbox-unusable-w.aspx[^]

                                          L 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