Getting identical objects to show in SQL Compare - tsql

Is there a way to get SQL Compare to output all objects, specifically stored procedures, in a database and not just those that differ?

In your compare results you should see a few different groupings. One being "identical objects". That one is on the bottom of my view. I am using SQL Compare 10.

If I want it to actually script all of the objects (rather than just see them in the results), I usually create an empty database and compare to that, then filter just to stored procedures and go through the synchronization wizard.

Related

SSIS or TSQL for SQL/MySQL table comparrison

I am new to SSIS and am after some assistance in creating an SSIS package to do a specific task. My data is stored remotely within a MySQL Database and this is downloaded to a SQL Server 2014 Database. What I want to do is the following, create a package where I can enter 2 dates that can be compared against the create date/date modified per record on a number of tables to give me a snap shot and compare the MySQL Data to the SQL Data so that I can see if there are any rows that are missing from my local SQL Database or if any need to be updated. Some tables have no dates so I just want to see a record count on what is missing if anything between the 2. If this is better achieved through TSQL I am happy to hear about other suggestions or sites to look at where things have been done similar.
In relation to your query Tab :
"Hi Tab, What happens at the moment is our master data is stored in a MySQL Database, the data was then downloaded to a SQL Server Database as a one off. What happens at the moment is I have a SSIS package that uses the MAX ID which can be found on most of the tables to work out which records are new and just downloads them or updates them. What I want to do is run separate checks on the tables to make sure that during the download nothing has been missed and everything is within sync. In an ideal world I would like to pass in to a SSIS package or tsql stored procedure a date range, shall we say calender week, this would then check for any differences between the remote MySQL database tables and the local SQL tables. It does not currently have to do anything but identify issues, correcting them may come later or changes would need to be made to the existing sync package. Hope his makes more sense."
Thanks P
To do this, you need to implement a Type 1 Slowly Changing Dimension type data flow in SSIS. There are a number of ways to do this, including a built in transformation aptly called the Slowly Changing Dimension transformation. Whilst this is easy to set up, it is a pain to maintain and it runs horrendously slowly.
There are numerous ways to set this up using other transformations or even SQL merge statements which are detailed here: https://bennyaustin.wordpress.com/2010/05/29/alternatives-to-ssis-scd-wizard-component/
I would recommend that you use Lookup transformations as they perform better than the Slowly Changing Dimension transformation but offer better diagnostics and error handling than the better performing SQL merge statement.
Before you do this you will need to add a Checksum or Hashbytes column to your SQL data for ease of comparison with the incoming MySQL data.
In short, calculate some sort of repeatable checksum as the data is downloaded into your SQL Server, then use this in an SSIS Lookup, matching on the row key, to check for changes. Where the checksum value is different for the same row it needs updating and where there is no matching row key in your SQL Data you need to insert the new row.

Using Data compare to copy one database over another

Ive used the Data Comare tool to update schema between the same DB's on different servers, but what If so many things have changed (including data), I simply want to REPLACE the target database?
In the past Ive just used TSQL, taken a backup then restored onto the target with the replace command and/or move if the data & log files are on different drives. Id rather have an easier way to do this.
You can use Schema Compare (also by Red Gate) to compare the schema of your source database to a blank target database (and update), then use Data Compare to compare the data in them (and update). This should leave you with the target the same as the source. However, it may well be easier to use the backup/restore method in that instance.

Delete Redundant Sql Server Stored Procedures

How to delete all redundant stored procedures in T-SQL? By saying "redundant", I am talking about SPs that may have different names, but work the same way -- same input, same output. The approaches can be different.
Here is the situation: 20-30 databases with hundreds of tables each, thousands of stored procedures which keeps growing everyday, no version control on stored procedures, and everything we did is on the production databases, no test databases.
Profiler and hard work are the answer. Set profiler to monitor the RPC:Completed event. Remove all possible columns and add the "Text Data" column. The output could be saved then parsed to find stored procedures which have the same paramertes and produce the same output. Check Stored procedure output parameters in SQL Server Profiler for more information on the results of the RPC:Completed event.

Joining output data of two T-SQL Stored Procedures from an SP

Right now I have two stored procedures that return data sets, and I'd like to create another stored procedure that executes both stored procedures and returns their combined datasets (to a .Net application).
Is this as simple as just running "EXEC" on both of the stored procedures or do I need to add in some logic that combines the two data sets?
You can just exec each SP one after the other and the application ('m assuming it's based on .NET) will see two result-sets. The results will not be combined into a single result though so you'll need to use DbDataReader.NextResult(): http://msdn.microsoft.com/en-us/library/system.data.common.dbdatareader.nextresult.aspx.
If you need the results to be combined into a single result as far as the application is concerned you'll need to insert the results of th SPs into two table-valued-variables and then SELECT-JOIN them.
Alternatively, and if possible, convert the two child SPs into table-valued functions and then SELECT-JOIN the results directly.

How do I "SET ROWCOUNT 1000" in ADO.NET?

I need to make sure my ado.net commands don't return more than 1000-5000 rows. Is there an ADO.NET way to do this, or is it just a TSQL?
I'm calling a stored procedure, I don't control the source code in that stored procedure. Hence I was hoping there was a ADO.NET way to do it.
Before LINQ this typically was always done using a top N clause in your inline query or stored proc. With LINQ there is some cool functions called "Take" and "Skip" which provides a construct for downloading and or skipping N number of rows. Under the hood LINQ figures out the details of how to construct the inline query that yields the exact number of rows you want off the top.
[Edit]
Since you're calling a stored procedure, I'd advise just using a TOP N clause in the select statement. This is path of least resistance and IMHO is the simplest to maintain going forward since you already have the stored procedure.