I have a Development and Production database and they are a little out of sink. Does any one know of a way to compare two databases (tables, fields, sp) and report the differences? Thanks in advance.
Trying to compare unique fields from two databases.
Basically what i'm trying to do is get all of the id's out of one field that don't exsist in the 2nd database.
so I have this query
Code:
select Distinct Id from table1 where ID!= (select Distinct ID from table2)
I'm getting this error
Server: Msg 512, Level 16, State 1, Line 1 Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Now I don't understand why because then I query select id from tables 2
I only get 1 value for each row.
Now you should know, the two columns in either table are different, in one of them the first value is "1" in the other the first value is "00000001" although I don't think that should effect anything.
i have two databases best and books.Most of the tables present in best are in books except some. i have been given a task to list out the tables and columns of which are present in best database and not in books database.
Pls suggest me the simplest and quickest way to do this. this is very urgent.
Hi,I would like to compare two sql server databases.I need to find the difference in the two database(i.e table, colums,data type)Is there any free utility available to compare sql server databaseI'm using sql server 2000.Help me out to compare databasesThanks & Regards,Mani
Hello,I would like to make a comparison between two databases in SQL server,to find differences between tables, procedures and so on.I have searched the web and found several softwares able to perform thetask, but none able to compare a database with a backup otained from aSQL Server database, or between two backups.Is this possible ? Is there a software able to perform such comparison?Thank you for your help.--L'amour, c'est un sport. Surtout s'il y en a un des deux qui veut pas.[Jean Yanne]
Im busy working on converting one DB to look like another one and I am using a data comparison tool to generate a script that I can hopefully use to upgrade an existing DB.
The problem is occuring with only one table and as soon as the script is run I receive the following error msg in SQL server 2005; ______________________________________________________________________________________________________ 'Patient' table - Unable to modify table. Cannot insert the value NULL into column 'ClinicCode', table 'DCS.dbo.Tmp_Patient'; column does not allow nulls. INSERT fails. The statement has been terminated. ______________________________________________________________________________________________________
Now the problem I am facing and I am hoping you could help with is where I can find the .Tmp table. This is obviously a temporary table created, but I have no clue as to how to alter the values of that temporary table in order to facilitate the changing of the table to coincide with the updated table.
Some help would be appreciated in this regard.
p.s. Hopefully I explained the problem sufficiently for you guys to help out!
Hi, I would like to know if it is possible to compare data in two different databases (both SQL7.0), with same exact schema. If possible, how could we do it?
Hi, does anybody know a nice tool to automatically compare and showonly the structural differences between two databases, this is, thedifferences in the columns of a table, constrains, data type, etc.ThanksJ.A.
I wan't to compare two SQL Server databases. i.e., I wan't to check both databases structure and add if necessary.
In my project I am using SQL Express database and now we update some fields in the database. So, if we wan't to update the new versions for those customers who are using old database we need to update the database also. It is not recommanded that to manually add the fields in the database and is time taking too. So, I wan't to compare two databases(old and new) and update the fields in the old database.
Any confusion in my question plz let me know so that I can be more clear.
Dear Readers,Is it possible, like in Access, to link to tables in other SQL databases that are on the same server? I have a query that I originally had in Access that queered from multiply databases. It did this by having those other tables in the other databases linked to the database that had the query.
Hi , I have three tables T1 , T2 AND T3. T3 is having fields as a combination of T1 and T2 fields.How can I compare T1 and T2 field values with T3 FIELD VALUES.
I have 2 seperate databases and I need to check for rows that are different from each other in a table.
I used access to link the tables in a database and am using queries to check the tables. However, I am having trouble formulating the SQL. What I want to do is not just check for the ID field to see if it exists, but to make sure the whole row exists. How can I form an SQL statement for this?
I tried something like:
Select * from table1 where Column1 NOT IN (Select Column1 from Table2) AND Column2 NOT IN (Select Column2 from Table2). However, I do not think this is correct. I want to make sure that the rows are compared, not individual values.
I've got two identical tables (except for the names) and I need to run a query that outputs the rows that aren't in the primary table.
To clarify table one has 38,450 records and table two has 30,703. I need to output the records that are in table one but not table two.
Everything I've tried keeps returning the records that are in it. They have a ID as primary key and a userid field which is what I want to be able to list.
How can I select records that have changed or are new when comparing a previous copy of a table with the live version of the table? There is no datetime stamp in these tables. Many thanks in advance.
I need to compare two tables and update the records that have changed. The following code works great for that: SELECT MIN(TableName) as TableName, ID, COL1, COL2, COL3 ... FROM SELECT 'Table A' as TableName, A.ID, A.COL1, A.COL2, A.COL3, ... FROM A UNION ALL SELECT 'Table B' as TableName, B.ID, B.COL1, B.COl2, B.COL3, ... FROM B ) tmp GROUP BY ID, COL1, COL2, COL3 ... HAVING COUNT(*) = 1 ORDER BY ID
However, I also need to compare the two tables and see if there are any new records or deleted records. What would those queries look like? Can they all somehow be combined into one query?
im currently doin my proj on asp.net, so i need some help on this.
i need to get a special price which muz be constant throughout all the pages which requires to show the product and the special price.
i haf 2 table which are products and promotion. and in products there is a column name price,productid, etc and in promotion, it displays the productid of the product which is having promotion and also a column name specialPrice.
i need to get the special price from the promotion tables.
so how do i go about retrieving wat i need for my databind specialprice.
ive tried using join, but there is cartesian, and i tried to use in, but its not constant throuh all the pages.
I am working with the article that MAK wrote on SecurityLogs http://www.databasejournal.com/features/mssql/article.php/3515886
I have completed this, but I have made some changes to the database (for normalization to 3NF purposes). I now have problems with a query.
I am trying to "Insert a new record in a table if it does not already exist in the table". To try to clarify I perform the following query:
INSERT INTO Tmp_Event SELECT DISTINCT EventID, EventType, EventTypeName from Tmp
Which gives me the Tmp_Event table consisting of EventID's etc. (no duplicates). What I then want to do, is compare the 'Tmp_event' table and an already existing 'Event' table. These two tables are in fact identical. I would like to insert any records from 'Tmp_Event' into 'Event' if they do not already exist in 'Event'.
This query gives me all records that do not exist in 'Event'
SELECT EventID, EventType, EventTYpeName from Tmp_Event WHERE EventID NOT IN (SELECT EventID from Event)
How can I change this query into performing an INSERT INTO Event as well?
I have two tables that share (supposedly) 2 fields (PartID and RaceID) and those two tables should be identical as far as those two fields are concerned. That is, there should be the same number of rows in both tables and if listed in the same sort order in reference to these two fields, they should be identical. The problem is, they are not. There are in excess of 3000 records in each field and I need to write a query that will allow me to compare them row-by-row.
I am using sql server 2000 and I am (kind of)familiar with the SQL Query Analyzer. What I really need to know is how to write the select statement that will allow me to compare the two tables line-by-line to find the discrepancies or, better yet, simply show the discrepancies so I can focus on them.
I would like to compare data across two tables. I have partinformation in a table. I get a new set of information periodically.I would like to compare my new info to my old info. I recognize thatdoing a compare of every attribute of every part will take FOREVER. Isthere some way I can do a "diff" based on the columns that I careabout?Thanks!--gloria
Hi,I'm trying to figure out a way to compare two tables, table one has moreentries than table two, I want SQL to compare table one to table two andspit out and XLS of the enries that exist in table one, but not in tabletwo.So far I can't even get my query right...hehselect * from table1 aleft join tabl2 b on a.column=b.columnwhere a.column exists not b.columnam I missing an "in" in the select portion on my query?thanks alot for any help.
I've successfully created SSIS packages where I compare two tables in different databases on different servers. However, this is good enough to compare hundreds of thousands of records quickly. The process becomes a huge performance problem when trying to compare table differences when I'm looking at tables that each contain tens of millions of records.
One database is on a SQL 2005 box and the other DB is SQL 7.0 so the lookup component fails for this type of SQL Server. I've been implementing merge joins and conditional components to do my standard table comparisons.
Is there another way to implement this process or maybe partition it somehow to take pieces of the table at a time and compare them? I'm open to ideas.
I have two tables in seperate dbs that I need to match up users and update the passwords in the second db table. I know how to match up the data and I'm sure I can do this using a cursor but I was wondering if there is a way I can do this with an update statement. Any suggestions(including telling me I'm stuck using a cursor) would be great.
I am trying to write an SQL command for my crystal report. I need to compare the same column in 3different tables & get the data from each table for only the matching data.. I understand I need to create a temporary table, get the data into it & then work around.. I am quite new to SQL.
Eg: Considering one customer account Table 1 Cust.No Name Amt_Counter AmtPaid 123.456 sam 0 0 123.456 sam 1 50
Table 2 Cust.No Name Freq_Counter Frequency 123.456 sam 1 0 123.456 sam 2 15
I am looking for an efficient mechanism to compare data between 2 tables/views.
Rationale: I use a proprietary tool to data transfer between 2 databases. The tool itself uses Microsoft SSIS (integration service) to transfer data. I want to make sure that the data is transfered properly. Both the source and target database are not live database. The source and target database are in seperate servers.
I have recently converted my DTS packages to SSIS and deployed them to the new server. I have the 2000 and 2005 server running concurrently, all that is left for me to do is compare the the tables generated by the DTS and SSIS packages to see if they are the same.
How do I go about comparing the tables, which are from two different servers using SQL server 2005?
and BSmith's idea (no relation), I came up with this silly stored proc to compare any two tables or views. Supply the table names and the columns you wish to compare and have fun!
The key to the GROUP BY approach is that it handles NULLS quite well which JOINS have trouble with.
-- Table1, Table2 are the tables or views to compare. -- T1ColumnList is the list of columns to compare, from table1. -- Just list them comma-separated, like in a GROUP BY clause. -- If T2ColumnList is not specified, it is assumed to be the same -- as T1ColumnList. Otherwise, list the columns of Table2 in -- the same order as the columns in table1 that you wish to compare. -- -- The result is all records from either table that do NOT match -- the other table, along with which table the record is from.
declare @SQL varchar(8000);
IF @t2ColumnList = '' SET @T2ColumnList = @T1ColumnList
set @SQL = 'SELECT ''' + @table1 + ''' AS TableName, ' + @t1ColumnList + ' FROM ' + @Table1 + ' UNION ALL SELECT ''' + @table2 + ''' As TableName, ' + @t2ColumnList + ' FROM ' + @Table2
set @SQL = 'SELECT Max(TableName) as TableName, ' + @t1ColumnList + ' FROM (' + @SQL + ') A GROUP BY ' + @t1ColumnList + ' HAVING COUNT(*) = 1'