Update field from ssrs - sql-server

Is there a way to update a field in a table from value already chosen in ssrs ?
I am looking to update a field year after choose the value in ssrs.

I agree with Nathan. However, you might be able to build a stored procedure and pass it a parameter from the report. The stored procedure would have an update statement that accepts your parameter as an input.
For example:
UPDATE Table
SET column = #parameter
You'll need to add a parameter to the SSRS report. If you build a stored procedure that accepts parameters they will show up in your report.

Old post, but wanted to provide an alternate solution if anyone runs across this question. You could also place your update query within the stored procedure you're calling. For example, if I wanted to update a field called DateReported prior to running my stored procedure to gather records, I could place it at the beginning of the stored procedure (before the select statement), and it would then execute prior.

You can do it before report rendering. After that there is no way to call stored procedure. You can not add a custom event on the report to fire in case of a selection.

Related

Take data from different datasets and inserting them into a SQL table from SSRS report

I have a SSRS report with 20 different datasets with some calculated columns in each.
I want to take few fields from all data sets including some calculated columns and insert them into a SQL table.
I want to do this for each month so that I can see the trends during a period. Is there any way to do that with out editing the data sets?
Can I refer the fields that I need by referring to Textbox4 and insert them into a SQL table? What is the easy way to do without touching data sets?
There is most likely alot better solution than using SSRS to update a SQL database. I am not proposing this as the best solution but rather a way to achieve what was asked.
You could create a dataset that runs a stored procedure you can pass the data as parameters to. The Sproc would do the insert into your chosen table and you can pass in the parameters from your original dataset however you see fit. You could even setup a second report with the Stored procedure Dataset that you can call on command by having an action event on an item to call the report. (I had a subreport embedded in a column of a tablix configured so it would only update with values from that row for instance).
To clarify:
Create a subreport that accepts the data you want to insert as a parameter for each column
Instead of adding a normal Dataset, have it call a stored procedure that inserts as you require
Add the subreport to your main report to be called once its run and configure the required parameters to be passed through.
There will be better, more efficient, cleaner ways to do this, but I found the above to work for my purposes since I was limited by time and resources. But I would still recommend you seek other solutions if possible.

How to update field/formulas in Crystal Reports from another data source?

I have copied text from a stored procedure (SP) in SQL Server and modified it and created a new stored procedure with a new name (Example spMyproc to spMyProc_a). I then updated a report in Crystal Reports that was using the original SP as its data source and substituted the new SP. However, the fields/formulas are still referencing the original SP.
Is there an easy way to remap the fields/formulas to reference my new data source? Or, will I need to update each one individually? Also, I cannot expand my new data source in the Field Explorer tree view. Am I doing something wrong?
In Crystal;
1. Select Database Menu
2. Set Datasource Location
3. Choose your current SP
4. Select "Replace with:" SP
5. Select Update and provide any parameters
6. Update the SP name in Field Explorer under Database Fields
OR;
In SQL create a dummy SP that executes the actual SP with the same parameter definitions.
In your report use the first SP as the datasource.
When you need to update the actual SP just modify the dummy to call the new SP. As long as the parameters and field definitions are the same there is no need to modify the report otherwise see above.

Calling a stored procedure for a column during select

I have a stored procedure named "OUTPUT_DATE" that takes in a date, and then outputs the date in the standardized format specified in another section of the database.
I am currently working on creating a BIRT report using this, however would like to call this stored procedure while getting the data to format a specific column of data. My question is, is it possible to call a stored procedure on my select statement, or is there another method to do this using BIRT?
I am already aware of the functions build into BIRT to output specific date formats, but this does not currently work the way I want since our date format is specified in the database.
My preference would be something similar to this...
SELECT col1, col2, OUTPUT_DATE(dateCol) FROM the_table
You can, but you should create a user defined function (scalar valued) instead of your stored procedure - functions can be called the way you want to.
Document & sample from Microsoft

Can a RDLC with a StoredProcedure dataset handle OUTPUT Parameter

I have many RDLC reports based on a StoredProcedure dataset on SqlServer.
My StoredProc have an OUTPUT parameter which receive an XML string with a list of ids to filter my table <ListXML><ItemId>10</ItemId><ItemId>11</ItemId></ListXML>.
I also want to show on my report header the formatted list of ids so users can see what they sent 10, 11.
So far, i'm handling the case with a CustomCode in the report properties using the System.Xml reference but i don't like having to use an external reference (especially while deploying the report on the server), the overhead of copy-pasting the code in each and every report and i'm concerned that my team will forget to copy the custom code and develop other solutions to handle the problem. I'd rather have my StoredProcedure return me the formatted string of Id to display on my report header.
i tested the case with a dummy sp
CREATE PROCEDURE [dbo].[Rep_Test]
#test VARCHAR(20) OUTPUT
AS
BEGIN
set #test = 'hello'
select top 10 * from item
END
and it revealed to me that it doesn't work right of the bat. Visual Studio does set 'Hello' as 'default value' to my parameter in the report but if i give a value to my report parameter it will not be overidden by the stored procedure.
Any insight on the subject or any other solution to handle the problem would be greatly appreciated
No. An RDLC cannot handle OUTPUT parameters in its dataset. You have to use a workaround.
One workaround is to employ a wrapper procedure that reads the resultset of the inner procedure, and adds another column with the value of the output parameter in every row.
A more detailed description with code can be found here.

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