Finding difference of two databases

Hi
I have a webapplication connected to SQL Server 2012 Web Edition.
As soon as the webserver is down I start a second webserver, which needs to have the same content, also on SQL DB level.
That’s why I take a backup of the SQL Server on the first server recovering it to the second server. This works fine.
The database name as well as the database user name are the same on both SQL servers. This database user has owner rights on database level. The configuration does not change, during recovery process on the target server, which overwrites
the earlier content state of the db.
For any reason the webapplication cannot connect to the database afterwards. Of course the contents of the html files in the IIS webfolders are identical on both servers.
The application connects via IP address 127.0.0.1 (not server name), database name, database user and password, all these parts have also been initially set on both servers in the same way.
It seems, that the two databases still have a slight difference.
Your input is welcome.
Patrick

The application connects via IP address 127.0.0.1 (not server name), database name, database user and password, all these parts have also been initially set on both servers in the same way.
It seems, that the two databases still have a slight difference.
When you restore a database to a different instance, there may be a SID mismatch between the login in the master database and the user in the user database.  This can be corrected with ALTER USER for a normal user:
USE MyDatabase;
ALTER USER YourDatabseUserName
WITH LOGIN = YourLoginName;
You mentioned database owner permissions (a questionable practice from application code).  If the problem login is the database owner, you can change the database owner (mapped to dbo user) with ALTER AUTHORIZATION:
ALTER AUTHORIZATION ON DATABASE::MyDatabase TO YourLoginName;
If this doesn't resolve the issue, please post the error message. 
Dan Guzman, SQL Server MVP, http://www.dbdelta.com

Similar Messages

  • Finding difference between 2 databases

    Hi Folks,
    I have the following problem:
    I have 2 databases, database old, database new. Database new has modified/removed/added/inserted rows. Also columns in the db can also be modified. So what I have to do is to find the set of SQL statements which if I execute on database old, will make database old same as database new. Modification is only in data, not triggers etc.,
    I have explained my manager that this is not very easy to implement. Even finding difference between 2 DB is not trivial. Do you guys have any suggestion for me? whether in terms of implementing it or even convincing my boss is fine :)
    Are there any open source tools to do this? I am in big trouble now :(
    Thanks,

    Unless there is some other goal that you have not mentioned this is fairly easy.
    Just delete all the tables from the old database using SQL delete tables and then create new tables and populate them with data from the new database.
    Your SQL is basically just a serialization of the data in your new database.
    Anything else that you could do, such as calculating the differences from the one database to the other, and then creating a minimal edit list that will make the least possible number of changes must be weighed against the time it will take to write the code to compute the differences, the time it will take to debug the code and convince yourself that it is doing the right thing, and the time it will take to actually run.

  • Get Differences between two databases

    Hello there,
    I need to check if there are differences between 2 databases, both on 10g. As I do not want to check all tables, triggers, procedures and so on manually I wonder whether there is a script where I just need to give the db_names for checking both databases?
    best regards,
    Jörn

    Hi there,
    first, I need to know structural differences like row datatypes, indexes or triggers. I don't need to know what exactly is different just which objects.
    Second, I would also like content - differences between two tables, so the exact table data compared to each other. But this is not as important as the first one.
    best regards
    Jörn

  • Bestway to find difference between two roles in quality and production

    We have a process of collecting su53 dump and then analyze for missing authorization . However some time although everything works fine in quality , it fails in production . Hence I want to know a simple methodology to compare roles in quality and production to know difference ... Can anyone share best methodolgy being used in your setup ?
    NPB

    (1)How to find the difference between two dates at Universe level and at report Level in IDT?
    DaysBetween ([Sale Date];[Invoice Date]) returns 2 if [Sale Date] is 15 December 2001 and [Invoice Date] is 17 December 2001.
    (2) How to change format of dates from YYYY/MM/DD to DD/MM/YYYY in IDT at prompt level ?
    =FormatDate(ToDate(YOUR DARE OBJECT);"YYYY/MM/DD");"dd'/'MM'/'yyyy")
    =To_Char (object name, required format)
    Find the below link for more info.
    http://scn.sap.com/community/semantic-layer/blog/2014/04/18/bi41-business-layer-enhancements--create-display-format
    (3)What is VIEWS in IDT of data foundation layer when we right click? could u plz give one example where exactly we use VIEWS?
    A custom data foundation view is a subset of the data foundation Master view. You can use views when editing a large data foundation, and interested in working with a subset of tables. You can define multiple custom views for the data foundation due to the complexity of the data warehouse.
    Essentially, need created views for each individual star scheme (like Sales, Production, Finance, Accounting, etc.) plus a view for eachcomplex dimension structure (like Business Partner, Material, Customer, Plant etc.),
    Find the below link for more info.
    http://scn.sap.com/docs/DOC-54422
    (4) How to represent & report my IDT data in dashboards? could u plz explain the steps?
    Please find the below link: http://scn.sap.com/docs/DOC-27559

  • Find Differences between two tables at column level

    Hi,
    I have 2 tables one live table and the other History table..
    If i have to find differences between live table and the latest version in the History table and also find which column got chaanged
    How would i do that for a table which has many columns and i need each column for which the value has changed for a id
    for ex:
      Table 1   (LIve)                           Table 2 (History)
    ID col1     col2    Version               ID       col1     col2    Version
     1   ABC     123     V1                     1       ABCD   123     v2
     2   NBS     1234   V1                     2        NBS     123     V2
    Result set should be 
    Result Set:
    ID col which changed
    1    col1
    2    col2   
    Because the values for that column had been changed
    Except gives me all the differences not just the column level ..

    The dynamic version using schema views... :D
    --Build a coulple OF testing tables to play with
    CREATE TABLE dbo.Table1 (
    ID INT IDENTITY(1,1) PRIMARY KEY,
    Col1 INT,
    Col2 INT,
    Col3 INT
    CREATE TABLE dbo.Table2 (
    ID INT IDENTITY(1,1) PRIMARY KEY,
    Col1 INT,
    Col2 INT,
    Col3 INT
    INSERT dbo.Table1 (Col1,Col2,Col3) VALUES
    (123,456,789),
    (111,222,333),
    (444,555,666),
    (777,888,999),
    (321,345,769),
    (179,753,758),
    (362,362,236),
    (856,874,896),
    (821,729,324)
    INSERT dbo.Table2 (Col1,Col2,Col3) VALUES
    (123,456,789),
    (111,999,333), --col2 diff
    (444,555,666),
    (777,888,999),
    (321,345,123), --col3 diff
    (179,753,758),
    (362,362,236),
    (234,874,896), --col1 diff
    (821,729,324)
    And then the actual solution...
    DECLARE
    @t1 VARCHAR(10) = 'Table1',
    @t2 VARCHAR(10) = 'Table2'
    IF OBJECT_ID('tempdb..#temp') IS NOT NULL DROP TABLE #temp
    SELECT
    c.TABLE_SCHEMA,
    c.TABLE_NAME,
    c.COLUMN_NAME,
    c.ORDINAL_POSITION,
    CASE WHEN u.COLUMN_NAME IS NOT NULL THEN 1 ELSE 0 END AS PK
    INTO #temp
    FROM
    INFORMATION_SCHEMA.COLUMNS c
    JOIN INFORMATION_SCHEMA.TABLES t
    ON c.TABLE_NAME = t.TABLE_NAME
    AND c.TABLE_SCHEMA = t.TABLE_SCHEMA
    LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE u
    ON c.COLUMN_NAME = u.COLUMN_NAME
    AND c.TABLE_NAME = u.TABLE_NAME
    AND c.TABLE_SCHEMA = u.TABLE_SCHEMA
    AND OBJECTPROPERTY(OBJECT_ID(constraint_name), 'IsPrimaryKey') = 1
    WHERE 1 = 1
    AND t.TABLE_TYPE = 'BASE TABLE'
    AND c.TABLE_NAME IN (@t1,@t2)
    ORDER BY
    c.TABLE_SCHEMA, c.TABLE_NAME, c.ORDINAL_POSITION
    DECLARE @select VARCHAR(MAX)
    SELECT @select = COALESCE(@select + ', ', '') + t.TABLE_SCHEMA + '.' + t.TABLE_NAME + '.' + t.COLUMN_NAME
    FROM #temp AS t
    ORDER BY t.TABLE_NAME, t.ORDINAL_POSITION
    DECLARE @from VARCHAR(MAX)
    SELECT @from = COALESCE(@from + ' FULL JOIN ', '') + t.TABLE_SCHEMA + '.' + t.TABLE_NAME
    FROM #temp AS t
    WHERE t.PK = 1
    ORDER BY t.TABLE_NAME
    DECLARE @on VARCHAR(MAX)
    SELECT @on = COALESCE(@on + ' = ', '') + t.TABLE_SCHEMA + '.' + t.TABLE_NAME + '.' + t.COLUMN_NAME
    FROM #temp AS t
    WHERE t.PK = 1
    ORDER BY t.TABLE_NAME, t.ORDINAL_POSITION
    DECLARE @where VARCHAR(MAX)
    SELECT @where = COALESCE(@where + CASE WHEN t.TABLE_NAME = @t1 THEN ' OR ' ELSE ' <> ' END, '') + t.TABLE_SCHEMA + '.' + t.TABLE_NAME + '.' + t.COLUMN_NAME
    FROM #temp AS t
    WHERE t.PK = 0
    ORDER BY t.ORDINAL_POSITION, t.TABLE_NAME
    DECLARE @sql VARCHAR(MAX) = '
    SELECT ' + @select + '
    FROM ' + @from + '
    ON ' + @on + '
    WHERE ' + @where
    EXEC (@sql)
    HTH,
    Jason

  • To find difference between two dates

    Hi all,
    I am new to this forum and oracle.
    I want to get the difference between two dates. My query is as below...
    sqlserver_utilities.datediff('YY', startdate,enddate)
    I want the difference in year.
    Please help me. It's really urgent.
    Thanks in advance.
    Regards,
    Inam

    Select to_char(enddate,'YY') - to_char(startdate,'YY') fromPLEASE don't do that. There are so many things wrong with it...
    for example:
    1). Why are you subtracting character data types?
    2). What if the start date is 1999 and the end date is 2000? Do you expect to get a difference of -1?
    3). What if the start date is 1 Jan 2000 and the end date is 31 Dec 2000? Do you expect to get 0 instead of 1 or .997?
    4). Why would you convert dates to something else when they are inherently subtractable.
    5). There are obvious points in the OP's "specification" that are vague - the best thing (after telling them to search, of course since this has been answered a million times already) would be to try to clarify the spec.
    John

  • How to find differences between two columns

    Hello I need the formula to spot differences between two columns and to write on a third one if the same name appear on the two columns.
    For example:
    rome berlin true
    berlin moscow false
    chicago toronto true
    toronto chicago true
    florence
    Thanks
    Lorenzo

    You should be able to use COUNTIF where the range is th first column and the condition is the word in the second column. If the result is greater than zero then the word is in both columns.

  • Find difference between two numbers (DBL)

    Hello All,
    Is there a function in labview other than subtraction function that can find the difference between the two given numbers?
    Thanks,
    Davidson
    Solved!
    Go to Solution.

    I think if he wanted to find absolute value he would have mentioned it.
    And not asked about other function for taking difference.
    Do you want to fight over this? When it is mentioned "DIFFERENCE" and not "ABSOLUTE" value.
    Anyways..Will fight tomorrow. I am going home.
    Best of luck
    Gaurav k
    CLD Certified !!!!!
    Do not forget to Mark solution and to give Kudo if problem is solved.

  • Detecting differences between two databases

    We've two big databases (20 Gb) on essbase 6.5 and System 9. We need to know if there are any differences between them. Is there a way to do that different from querying both databases with a lot of reports and comparing them?
    Any suggestion will be helpful.
    Thanks and regards,
    Joaquin Castellano

    You can compare two dbs with something I call a difference cube. For example, lets say you have two 5 dimensional databases that are very similar. Perhaps you made some changes in calcs and want to see the impact. Call the cubes Before and After . You could make a third copy and add a dimension. The members of the 6th dimension would be Before, After and Difference. Put a calc on Difference = After-Before. You can load the 5 dims worth of data from before to the before member and the same thing with after. You need to either use a rule with a header or you can use @XREF or partitioning. You can actually zoom and pivot through the resulting cube to identify differences.
    There are some tricks to getting it right.
    The first is to load the 5D data to the 6D cube. That's really not hard if you know how to use @XREF or parititioning or headers in a rule. I can explain this in detail or if you like I'll show you via a webex support session.
    The second issue is size. If the first cube is 10gb then you will end up with 30gb for three versions. But you can moderate that by adding the 6th dimension to the Test cube and using dynamic XREFs.
    Here is a link to a pdf that helps explain the process.
    http://www.mtgny.com/Difference%20Cubes.pdf
    If you send me your email address I'll send you some Maxl that will do the whole job for you with just a little tweaking for for your cube names etc.
    Other things to look at include the outline chnage log file and the OLAP underground outline extractor to compare outlines.
    Hope this helps. Please contact me if you need more info.
    Ron
    [email protected]

  • Find difference between two vectors ?

    Hi,
    I have two vectors, the first contains:
    v1.add("1");
    v1.add("2");
    the second:
    v2.add("1");
    Now I want to print out the difference between both.
    Does anybody have en idea ?
    Regards
    Micha

    Yep, that should definitely do it. I think the point ssav is trying to make is that to solve this problem we need to know your actual requirements. "the difference between" is too vague. Here are some things to think about:
    - Is position important? That is, is a List containing 1 and 2 the same as a List containing 2 and 1 or different?
    - If List A contains 1,2,4,5,6 and List B contains 1,2,3,4,5,6 what would you want to see?
    - What if List A contains 1,2,3 and List B 1,2,2,3?
    - What if List A contains 1,2,3 and Lits B 1,2,and a java.lang.NullPointerException?
    You're probably starting to see that this is not as simple as you thought. Come back with more specific requirements and you may get better help.

  • Oracle 11g sql to find difference from two table data

    I have two tables ACTUAL AND ESTIMATE having unique column(sal_id, gal_id) and amount, tax, date columns.
    ACTUAL table
    actual_id, sal_id, gal_id, process_flag, amount, tax     date
    A1 101 201 Y 10 1 27-Aug-12
    A2 102 202 Y 20 2 27-Aug-12
    A3 102 202 N 30 3 29-Aug-12
    A4 302 402 N 40 3 30-Aug-12
    ESTIMATE table
    estimate_id, sal_id, gal_id, process_flag, amount, tax  date
    E1 301 401 Y 5 1 19-Aug-12
    E2 302 402 Y 45 4 20-Aug-12
    E3 302 402 Y 50 5 25-Aug-12
    E4 301 403 Y 10 2 27-Aug-12
    E5 301 403 N 15 3 28-Aug-12
    E6 101 201 Y 12 3 29-Aug-12
    Now My FINAL table, 1) Should have record for unprocessed (process_flag='N') from ACTUAL/ESTIMATE table for difference in amount and tax for (sal_id + gal_id) combination. If more than one processed record there, then max (date) should be consider.
    FINAL table
    actual_id, estimate_id, sal_id, gal_id, amount, tax
    A3 null 102 202 10 1 (A3-A2 actual-actual)
    A4 null 302 402 -10 -2 (A4-E3 actual-estimate with max date)
    null E5 301 403 5 1 (E5-E4 estimate-estimate)
    null E6 101 201 2 2 (E6-A1 estimate-actual)
    So basically I need a query for (A-A) U (B-B) U (A-B) U (B-A).
    I am using Oracle 11g Please help me.
    Edited by: Suresh on Aug 31, 2012 7:38 PM
    Edited by: Suresh on Aug 31, 2012 7:38 PM
    Edited by: Suresh on Aug 31, 2012 10:53 PM

    You need to provide better explanation here.A-A is always null.
    You might be looking for something like this..
    Untested version and also i cannot read your mind
    select actual_id, sal_id, gal_id, process_flag,ld_amount,ld_tax,e_date
    from(
    select actual_id, sal_id, gal_id, process_flag,e_date, amount-lead(amount) over(partition by sal_id, gal_id order by e_date desc) ld_amount,
    tax-lead(tax) over(partition by sal_id, gal_id order by e_date desc) ld_tax,
    rank()  over(partition by sal_id, gal_id order by e_date desc)rnk
    from
    (select * from actual a union
    select * from estmt e)
    ) where rnk=1

  • How to find difference in two tables

    Hi all,
    I am having 2 tables (Table1 and Table2 ) same structure.
    1. Table1 is having some data.
    2. Now, i got data in CSV file, which was loaded into Table2.
    This data contains....
    A. Data of Table1
    B. Some colum values are different compare to Table1 column values.
    (Pkey is same, but column values are different in Table1 and Table2)
    C. Additional rows are there compared to Table1.
    Now, what i want is......
    I want to select the data from Table2,
    1. The rows in which column values are different from the Table1
    2. New records added from CSV file (i.e. Those records that are not
    there in Table1).
    Thanks in advance,
    Pal

    Thanks for your solution. It is working, but my problem is
    Table1
    COL1     COL2     COL3     COL4
    1     col2     col3     col4
    2     col2     col3     col4
    3     col2     col3     col4
    4     col2     col3     col4
    Table2
    COL1     COL2     COL3     COL4
    5     col2     col3     col4 -- New row
    6     col2     col3     col4 -- New row
    1     col2     col3     col44 -- Different column value
    2     col2     col3     col4
    3     col2     col33     col4 -- Different column value
    4     col2     col3     col4
    select * from test2
    minus
    select * from test1
    COL1     COL2     COL3     COL4
    1     col2     col3     col44 --- needs to be update
    3     col2     col33     col4 --- needs to be update
    5     col2     col3     col4 --- needs to be insert
    6     col2     col3     col4 --- needs to be insert
    Actually, I need to update and insert those records through LIVE UPDATE in the remote database. In this case, Table1 data is in the remote database. The output of MINUS statement needs to be implimented in Table1, which is in remote database.
    Any suggestion will be appreciated. Thanks,
    Pal

  • Difference between two Database s in CRM

    Hi All,
    Can anyone explain in details to me the functionality of CDB (Consolidated Database) and CRM Online Database?
    Regards
    Siddhartha Sengupta

    Hi Siddhartha,
    CRM database is an operational database for all crm operations
    CDB database is a copy of CRM database, it is maily use for Offline usage.
    It can be said that what ever content you require for offline useage you replicate in CDB from CRM. CRM and CDB are always in sync with each other.
    help.sap.com/saphelp_crm50/helpdata/en/cc/7c4a5b4632d411ab370060b03c3b0b/content.htm
    Best Regards,
    Pratik Patel
    <b>Reward with Points!</b>

  • Difference between two timestamp.

    Hi,
    I want to find difference between two timestamp in minutes.
    Actually i want to retrieve difference between current timestamp and the timestamp taken from the table
    select log_time from serv_info where server_id = 1;
    Can anyone tell me the query to find difference between two timestamps in minutes.
    -haifriends

    SQL> WITH serv_in AS
         (SELECT SYSTIMESTAMP - 1 / 4 log_time,
                 SYSTIMESTAMP now
            FROM DUAL)
    SELECT log_time,
           now,
             24 * 60 * EXTRACT (DAY FROM (now - log_time))
           + 60 * EXTRACT (HOUR FROM (now - log_time))
           + EXTRACT (MINUTE FROM (now - log_time))
           + 1 / 60 * EXTRACT (SECOND FROM (now - log_time)) diff_in_minutes
      FROM serv_in
    LOG_TIME  NOW                                 DIFF_IN_MINUTES
    01-MRZ-07 01-MAR-07 03.47.42.107462 PM +01:00      360,001791

  • Difference between two files

    Hi, I need to find difference between two files.
    This is an example:
    oldfile.txt:
    This is the old file.
    I need some help with
    this task!.
    newfile.txt:
    This is the new file.
    I need help with this task please!.
    Differences:
    * old -> new
    * need -> need
    * "some" was deleted
    * please was added
    Notice that I don't care spaces, new lines or tabs.
    The code should looks like:
    enum DifferenceType { Added, Deleted, Replaced };
    class DiffText {
      public String Text;
      public DifferenceType Type;
      public String ReplacedText;
      Diff d = new Diff("oldfile.txt","newfile.txt");
      while(!d.end()) {
        DiffText dtext = d.getNext();
       String s = "";
        switch(s.Type) {
          case Added:       System.out.println(s.Text + " ~ added");
          case Deleted:    System.out.println(s.Text + " ~ deleted");
          case Replaced: System.out.println(s.Text + " replaced by " + s.ReplacedText);
      }Thanks for your help in advance.

    Suppose you have two arrays filled with integers.
    What you want to do is map the integers from one
    array to the other.
    In your example, your arrays would look like:
    this is the old file i need some help with this task
    [0 1 2 3 4 5 6 7 8 9 0 10]
    this is the new file i need help with this task please
    [0 1 2 11 4 5 6 8 9 0 10 12]
    Here, I've assumed you've removed all punctuation and
    new line characters, and changed to lowercase.
    The easiest way is to walk through the arrays greedily.
    However, you may be able to research algorithms that
    do a better job of matching.

Maybe you are looking for

  • Tried to rip a CD with adhesive label - am I doomed?

    I've successfully ripped a few hundred CDs on my Mini. Then yesterday, it came to a complete stop while ripping one. When I ejected it, I realized the artwork on top was on a thin sticky label, not printed directly on the CD. A sinking feeling began.

  • How to retrieve data from a DB

    Hi I need to retrive data from a DB but I know nothing about DB structure and data type. I've been reading tutorials and writing code and I've all ready except I dont figure out how to know which data type I'm retrieving to use corresponding class to

  • GRC 10 - SSO via Portal - how to redirect url in notification variables

    Dears, I am in the process of designing our GRC 10 machine to be accessed via SSO in the Enterprise Portal. Yet I cannot find any info on what will happen with the URLs that are placed by ARM MSMP workflow in the variables of notifications/approvals.

  • Reporting on the difference between to dates

    Hello, I was wondering if anyone has created a report that is able to provide the number of days left untill a date is reached in Opportunity report. This is what i got so far but it isnt working: TimestampDiff (SQL_TSI_DAY, Today(),Opportunity."Clos

  • USB Mic Shows up but not working

    I have a USB mic to be used for dictation. When I had Tiger it would show up and when I would select it as an input device I would get "bars" on the sound control panel, but never really worked for recording. Now on Snow Leopard it shows up on my dev