compare 2 different databases table columns - sql

I need to compare DB tables from 2 different DB's to see where the differences lie, is there a simple tool or script for this?

redgate SQL Data Compare

It also possible with a Visual Studio Team Edition for Database Professionals 2005/2008 or Ultimate 2010. More details you can find on MSDN

if you want to compare missing rows you can do something like this
select id from db1.dbo.table1
where id not in (select id from db2.dbo.table2)

AdeptSQL Diff to compare structures of database/tables
http://www.adeptsql.com/

RedGate Data Compare is the one... Look no further. Once you start using you can't use any other tool. I'm not affiliated with this company, I'm just a fan of their product suite.

Related

Compare 2 Database all rows - different rows = output

i need a little bit help.
I have a developer DB (dev_home), in this db are many tables.
I need a compare to another DB (real_home).
The Tables are the same, but the table_names not!
For example i develop # dev_home, in the table personal.
In this table i've created new field, which are not exist in #real_home DB.
There are tools that do this i.e. compare two different instances of a database or two different databases etc ..
Such as
Red-Gate's SQL data comparison tool
or
You can also use Microsoft Visual Studio 2015 Community Edition (Free)

I need to compare column structure of two tables in different databases but on the same instance in SQL Server 2016

I need to compare column structure of two tables in different databases but on the same instance in SQL Server 2016!
Use System Information Schema Views. This should get you started:
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
Use this query to get information of column structure in a database and compare against another db
use DB
select *
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME='YourTableName'
This is external software, but unless you have Visual Studio premium where the functionality is built in, you can use something like Red Gate Schema Compare as a trial version to compare and generate a script to synchronise your tables, stored procedures etc.

compare data in sql server databases

I have a sql sever database on 2 servers. The structure of it is the same on both. A problem that I have is that I want to copy data between both databases - but the problem is I need to drop and recreate all the constraints first.
Any quick and easy way to script the differences between both databases, regarding data?
Yes, stop spending hours and hours trying to write a script that does this. Use a tried and true tool that handles all of that effort and debugging for you:
http://www.red-gate.com/products/sql-development/sql-data-compare/
There is a trial edition and there are several alternatives as well. Read this to see why you shouldn't re-invent the wheel:
http://madelinebertrand.com/2012/04/20/re-blog-the-cost-of-reinventing-the-wheel/
Just throwing my 2 cents in. If you have Visual Studio 2010 Premium or Ultimate, you can actually use feature called "Data Compare" to compare data between two databases. And it will be able to generate update script for target database as well.
I can only repeat the same opinion as Aaron Bertrand has, and to add to that, I had success using XSQL for this kind of task.
As far as I remember, it was a nice, consistent tool to use...
First you would need to turn the constraints off by altering the table in question such as:
alter table [table name] nocheck constraint all
Then you could query from the other server by linking or query directly using the following format:
select [cols] from [local table], [remote server.remote DB.remote table]

Best way to generate random data into a database

What is the best method to generate random data in SQL database lke name surnames tel no etc?
Is there any tool available that can do this for you?
Basically I have a database and I would like to fill it out with demo data....
Thanks!
If SQL Server Redgate SQL Server SQL Data Generator does this.
http://www.generatedata.com/
This tool gives us the ability to download in a variety of formats, including the command for inclusion in the database

SQL schema Table compare

I'm looking for an app that will compare the layout of 2 SQL tables. When developing in a DEV environment, I need a tool that will make the production tables exactly like the DEV tables (the layout).
SQL Compare from Red Gate and ERWin are two tools that work. Neither are free
I wrote a program called "SQL Server Comparison Tool" (SCT for short). You can try it for free for 30 days; I can extend that period to 90 days.
You can download SCT from www.sql-server-tool.com
SCT can compare both structure and data. You can "record" comparisons so that you can "re-play" them later without need for entering parameters again.
BeyondCompare can do this for you I believe.
You can try to use the SQL Examiner tool from the SQL Accessories.