There are two stored procedures which has same name and same logic. But in different databases. Only some of the content names are different (example - Synonym Name, Table Name, schema). Other code is the same.
Is there any way to compare code between above two stored procedures?
Personally i prefer to use a SSDT Project (SQL Server Data Tools)
It allows you to store the entire database schema in a Visual Studio project and in git/svn.
It is capable of comparing two databases (in full) or a database with the SSDT project schema. It will show you the differences and allow you to publish those differences.
Configurable and powerful.
I highly recommend it.
For many type of comparisons (folder, text, etc.) you can use Beyond Compare (they offers 30 days trial, but after it, you can simple reinstall it).
If you want something free, you can use a compare plugin for NotePad++ but is not so fancy as the first tool:
The Plugin Manager can be opened from Plugins -> Plugin Manager -> Show Plugin Manager.
I am using the file comparison tool 'Araxis Merge' to compare files in my project.
Please check the link to download the tool - http://www.araxis.com/merge/index.en
You can download the 30 days free trial version also.
Even though the source code for stored procedures can readily be retrieved from the database, they should really reside in a VCS for any database that is (or will be) productionised.
Historically, this has been something of a manual process but later versions of Visual Studio include the SQL Server Database Project type which makes development and deployment much easier.
The question then becomes the far easier one of how to compare files within the VCS which is typically trivial as this sort of thing is generally provided out of the box.
Aquastudio does it pretty well.
So i have a database in visual studio and now i am trying to get a relationship diagram between the tables.
However on searching the internet it says this feature is not avaiable in sql server 2012.
So is there any way i can extract relationship diagram automatically otherwise i will have to make the whole thing manually which is quite time consuming.
There are a number of software tools that can create a relationship diagram, such as Microsoft Visio Professional (but not Visio standard), or DBVisualizer. The latter is available as a free "crippleware" version that may still do what you need.
I'm using Visual Studio 2012 to compare my development database project with an existing databases. The existing database have some customized tables, stored procedures and functions, that I want them to be ignored.
My first thought is using Security Schemas, and i found this workarround:
Visual Studio 2010 - Schema Compare - Specify Database (Security) Schema
Is there any other solution?
Is there a way to automatize a task to generate a scripts with the differences? Something like the TFS automatic builds?
It's obviously been a couple of months since you asked this, but as far as I'm aware this isn't yet possible with schema compare / SSDT.
This sort of functionality is possible with third party tools such as redgates Sql Compare (by using filters), but I know that's not the question you asked.
If you have found out how to do it in the meantime, please let me know! :)
how to update database structure using script?
I have old db in one server and new db in another server, I have to update the old db structure with new one. Can we do using script?
Please any one help me
Thank you.
There are really great tools that do this. Sql Compare from Red Gate is excellent and I've used it often to do this kind of thing.
SQL Compare is the industry-standard
tool for comparing and synchronizing
SQL Server database schemas. It's used
by over 200,000 developers, DBAs and
test engineers worldwide because it's
easy to use, it's fast, and it saves
time.
Whether you are working with live
databases, database snapshots, object
SQL scripts under source control or an
earlier backup, SQL Compare will help
you compare and synchronize database
changes quickly, simply and with zero
errors.
Read the whitepaper on database
development and discover how SQL
Compare can save you astonishing
amounts of time, whatever development
model your team prefers to use. SQL
Compare ensures accurate, fast results
with maximum end-user
You'll need some sort of structure comparison tool.
There are many on the market (none built-in), my personal favorite is SQL Delta:
http://www.sqldelta.com/
It enables both Structure comparison (and update scripting) and data comparison and scripting, with both possible from the command-line. (and it's quite cheap).
This question already has answers here:
What is a free tool to compare two SQL Server Databases? [closed]
(7 answers)
Closed 3 years ago.
I would like to compare two SQL Server databases including schema (table structure) and data in tables too. What is best tool to do this?
I use schema and data comparison functionality built into the latest version Microsoft Visual Studio 2015 Community Edition (Free) or Professional / Premium / Ultimate edition. Works like a charm!
http://channel9.msdn.com/Events/Visual-Studio/Launch-2013/VS108
Red-Gate's SQL data comparison tool is my second alternative:
(source: spaanjaars.com)
http://www.red-gate.com/products/sql-development/sql-compare/
http://www.red-gate.com/products/sql-development/sql-data-compare/
I like Open DBDiff.
While not the most complete tool, it works great, it's free, and it's very easy to use.
I am using Red-Gate's software:
http://www.red-gate.com
SQL Admin Studio from http://www.simego.com/Products/SQL-Admin-Studio is now free, lets you manage your SQL Database, SQL Compare and Synchronise, Data Compare and Synchronise and much more. Also supports SQL Azure and some MySQL Support too.
[UPDATE: Yes I am the Author of the above program, as it's now Free I just wanted to Share it with the community]
I'm partial to AdeptSQL. It's clean and intuitive and it DOESN'T have the one feature that scares the hell out of me on a lot of similar programs. One giant button that it you push it will automatically synchronize EVERYTHING without so much as a by-your-leave. If you want to sync the changes you have to do it yourself and I like that.
There is one tool with source code available at
http://www.codeproject.com/Articles/205011/SQL-Server-Database-Comparison-Tool
That should give flexibility as code is available.
dbghost is the best i have used to date. one of the best features i have seen is that it will generate SQL code to go between versions of a database based on the SQL you keep in source control, as well as a database. simple and easy to use.
I've used SQL Delta before (http://www.sqldelta.com/), it's really good. Not free however, not sure how prices compare to Red-Gates
Try DBComparer, it's free and fast:
http://dbcomparer.com/
Database Workbench can made it too
http://www.upscene.com/products.dbw.index.php
Cross database development
Use the Schema Compare and Migration
Tools to compare testing and deployed
databases, migrate existing databases
to different database systems.
you can also made it with database Comparer
http://www.clevercomponents.com/products/dbcomparer/dbcomparer.asp
I use it for Firebird and it works well.
Try dbForge Data Compare for SQL Server. It can compare and sync any databases, even very large ones. Quick, easy, always delivers a correct result.
Try it on your database and comment upon the product.
We can recommend you a reliable SQL comparison tool that offer 3 time’s faster comparison and synchronization of table data in your SQL Server databases. It's dbForge Data Compare for SQL Server and dbForge Schema Compare for SQL Server
Main advantages:
Speedier comparison and synchronization of large databases
Support of native SQL Server backups
Custom mapping of tables, columns, and schemas
Multiple options to tune your comparison and synchronization
Generating comparison and synchronization reports
Plus free 30-day trial and risk-free purchase with 30-day money back guarantee.
We are using an inhouse developed solution that is basicly a procedure with arguments of what you want included in the comparision (SP's, Full SP code, table structure, defaults, indices, triggers.. etc)
Depending on your needs and budget, it might be a good way to go for you as well.
It is quite easily developed as well, then we just redirect output of procedure to textfiles and do text comparisions between the files.
One good thing about it is that its possible to save the output in source control.
/B
I've used Red Gate's tools and they are superb.
However, if you can't spend any money you could try Open DBDiff to compare schemas.
I would definitely go with AdeptSQL if you're using MSSQL. It's the least good looking but the most talented db compare tool amongst the ones I've tried. It can compare both the structure and the data. It tells you which tables exist on one db but does not exist on the other, compares the structure and data of the common ones and it can produce the script to synchronize the two. It's not free but has a 30 day trial (as far as I can remember)
I tried OpenDiff Tool . Great tool that is free and easy to use .