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

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.

Related

Azure Data Factory V2 - Calling a stored procedure that returns multiple result set

I want to create an ADF v2 pipeline that calls a stored procedure in Azure SQL Database. The stored procedure has input parameters and would return multiple result sets (around 3). We need to get it extracted. We are trying to load to Blob storage of 4 different files or load to table.
Is there a way to perform in pipeline?
In SSIS there is option to use script component and extract. https://www.timmitchell.net/post/2015/04/27/the-ssis-object-variable-and-multiple-result-sets/
Looking for suggestions in Data factory.
You cannot easily accomplish that in Azure Data Factory (ADF) as the Stored Procedure activity does not support resultsets at all and the Copy activity does not support multiple resultsets. However with a few small changes you could get the same outcome: you have a couple of options:
If the code and SSIS package already exist and you want to minimise your refactoring, you could host it in ADF via the SSIS-IR
Maybe you could accomplish this with an Azure Function which are kind of roughly equivalent to the SSIS Script Tasks, but it seems like a bit of a waste of time to me. It's an unproven pattern and you have simpler options such as:
Break the stored proc into parts: have it process its data and not return any resultsets. Alter the proc to place the three resultsets in tables instead. Have multiple Copy activities which will run in parallel, copy the data to blob store after the main Stored Proc activity has finished, something like this:
It's also possible to trick the Lookup activity to run stored procedures for you but the outputs are limited to 5,000 rows and it's not like you can pipe it into a Copy activity afterwards. I would recommend option 3 which will get the same outcome with only a few changes to your proc.

Talend Tmysql Component to run stored procedure?

I know there are tmysqlrow and tmysqlsp components available in Talend but it is fine if we use tmysqlinput to run stored procedure?
It depends on your requirements but generally you can use all of those components.
tMysqlSP
is there for convenience.
tMySqlRow
allows much more freedom.
tMySqlInput
is usually being used to get a result from the database. If you stored procedure doesn't return rows, which is sometimes the case, the following elements of the job might not run then.
So I would use one of the two first ones.

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.

Getting identical objects to show in SQL Compare

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.

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.