SSRS stored procedure with temp table - sql-server

I have a stored procedure which extracts data and dump into a temp table. I have created a ssrs report to extract data from the stored procedure. But I believe ssrs is not able to identify the temp table and retrieve data to the report because to test my report I dropped the stored procedure and re-created, but without executing the stored procedure I tried to run the report. But still it shows data. I want to know how ssrs identify the temp table and extract data to the report.

There may be two possibilities.
The first is that even though you dropped the Stored Procedures you don't say that you dropped the Temp table. Depending on if you used #Temp or ##Temp, the temporary table may persist.
The second possibility is that you are seeing the stored data from Visual Studio. If you check your RDL file location, there should be a .DATA file with the data that SSRS retrieves. Many times it will re-use this data if nothing has changed with parameters or query changes.

Related

Hide part of stored procedure and resultset data columns in SQL Server

I want to hide some part of my stored procedures even when a user uses sp_helptext. Because I want to maintain some security purposes.
I even wanted to hide some of the data columns in the result set of the stored procedure.

Monthly report automated with VBA + SQL Server Stored Procs?

I am trying to completely automate this process, and I'm wondering if its viable or efficient to do in VBA.
Report process involves 2 files: one sql file and one excel file.
SQL file has the algorithm, and the final step is a query who's result is then pasted into the excel file.
The algorithm is simpler(than what the audience might be used to) but has two "into" commands and several "update" commands.
Two "into" commands, the first grabs a small portion(constrained on first and last day of previous month) of a 500m+ record table. The second joins the first table with an eligibility type table.
After the second table is created, there is a series of UPDATE commands that change existing data of existing columns.
Then a series of ALTER & UPDATE commands that add new columns to the [second] table and UPDATES them with desired data.
the final step is a query who's results are copy-pasted into excel (as is, no formatting changes necessary).
I'm not too well-versed in VBA/VBNET nor TSQL stored procedures and dynamic sql, if the sql algorithm was a simple pull query with no table creation, I can build something to automate that. But the SQL has 2 table creations, and about a dozen ALTER & UPDATE commands.
Am I stirring up the wrong nest? Should I run it manually as is?
You can definitely do automate this. I created a report that ran two stored procedures and created numerous queries with temp tables including both update and alter commands then used VBA to run execute these and aggregate the data in the final summary sheet.
There is a ton of documentation out there. You can even pass your values to the stored procedure after the user inputs them.
I would add this as a comment but I do not have enough reputation to comment yet (need 50).

Suppressing output from a stored procedure in SQL Server 2008 R2 and newer

I am currently working with a stored procedure that performs some background processes and then returns one of two results tables.
If it works ok I get a one column table that says success, if it doesn't then I get a four column table with various error data.
While this is fine if you just execute the code from .net, I now need to execute this from within another stored procedure. While I don't need the output, I do need the background processes to take place. I'd usually insert the output into a table, but can't in this case as the columns in the output varies dependent on the result, and as such cannot define a table that it can insert into.
Easiest answer would be to rewrite the outputs of the background SP to be consistent but this isn't an option. I've even tried wrapping this inside a UDF but the stored procedure can't be called from with a function.
Whatever solution I finally use it must work on versions from SQL Server 2008 R2 up to 2016.
Does anybody have any suggestions?
Many thanks,
Mat.
I would image you could create a SP that inserts the result of the inner SP into a temporary table using the hack below.
Insert results of a stored procedure into a temporary table
If that blocks the ouput then you can return no data.

Using the resultset of a stored procedure in another stored procedure

We are using SQL Server with ColdFusion. We have a stored procedure that takes 15 parameters, performs one query and returns a resultset (a temporary table with two columns). Based on this resultset, a pie chart is produced where the user can choose one segment of the pie and a report is produced only for that segment.
The chosen segment of the pie chart is a parameter I will use (in a second stored procedure probably) to filter through the resultset of the first stored procedure to get the results for the new report. Many users can use this combo with different parameters so I can't insert the resultset into a table.
Is there any way I can do this without executing the stored procedure twice?

Report Variable Values from Stored Procedure onto SSRS Report

I have a stored procedure with 3 nested loops which works perfectly in Query Analyzer.
I need to create an SSRS report to output the data from the stored procedure.
The stored procedure uses several variables to hold calculated data for the output as it loops through the code.
How do I pull those variables onto my SSRS report? When I add the variables as parameters, SSRS errors with "parameter is missing a value". The value is derived from the stored procedure. I have not found a way to make this connection.
Its very annoying but you can only return one set of rows from a proc and for you to pass back anything it has to be in that table. So you will have to add columns to the passed back table which will contain the values you want on your report. I know this means that if you have a thousand rows these values will repeat 1 thousand times but that is the only way to return them.

Resources