XML Datasource From Database Column in SSRS - reporting-services

First, a little background:
We have been using SSRS in LocalMode for processing. We have an Object Data Source we've been using. This Object is serialized from an XML column in the database.
We're now forced to move to Server Mode due to memory leaks in Local Mode. As such, I'm rebuilding the reports. The problem I've run into is that I want to pull the XML data out of the database as an object but can't seem to figure out how to do this. I know I could create a web service or URL to provide it to the SSRS, but I want to avoid this if possible.
Is there a way to pull an XML column from a DB Data Source and get all the elements of it as the "Fields"?

Are you asking how to query xml from on the SQL Server? There's plenty of query examples online. It still returns as a dataset but you can modify it in custom assembly to return a String that can become the query for your xml dataset inside the report.

Related

Reading from SQL and passing it to C# method

I need to read a column from a database table depending upon some parameter. If the database table has two columns, status and ID, then I have to read the ID if the status is true. Then I have to pass this ID to a C# method.
How can I achieve this in SSIS? So basically my database package will read the data from SQL Server and pass it to a C# method.
SSIS is an ETL Tool for moving and transforming large quantities of data. If you need to do a lot of C# work and you only have one record, or a few records, SSIS may not be the right tool for this purpose. You might do better writing an ASP.NET web application or a Windows application. These applications can also use SQL to get data for processing in C#.
If you are determined to do this in SSIS and C#, here are two possible approaches:
You could use an Execute SQL Task to perform your query and save the rowset into a variable. Then you would use a C# Script Task to do something with the contents of the variable.
You could create a Data Flow Task. The dataflow should have the structure Source -> Transformation -> Destination, and can include several transformation components.
You would use, for example, an OLE DB Source Component to perform your query. Then you would use a C# Script Component to transform each record that is returned by the query. Finally, you would use a OLE DB Destination Component to do something with the output for each record.

SQL Server Reporting Services (SSRS)

I am new to SSRS. I use SSRS to access a remote data source. I can use the interface shown below to build and execute queries and produce reports:
Is there a way to build a report by specifying the SQL directly rather than using the graphical tools. I have spent some time Googling this and I have gone through a few tutorials. I am unable to find an answer.
Click the Edit as Text button in the top left-hand corner of that window and have at it.
Edit If you are only seeing XML in the query window, then you are using a Report Model data source instead of a direct database connection. Models cannot be queried directly with SQL.
In order to query with SQL, setup a Data Source using a connection string that points directly your database.

Should I use SSRS or SSIS?

I have an Oracle query and I want to export the query results to an excel file daily. I've looked into both SSRS and SSIS and am not sure which would be better to use.
The query is a normal select that returns 10-20 fields. It is pretty straight forward with a couple joins and where clauses. It selects DISTINCT to get rid of duplicate rows.
It's a straight mapping from the query to the excel file.
Does SSIS have performance advantages over SSRS?
I was leaning toward SSRS because it's very simple to set up and there are added benefits of being able to easily run our extract/report with different dates through the SSRS web UI.
SSIS seems like it will be more complex to set up, but still simple. However, it seems I would have to handle how to rename the extracts without using the main excel "template" so there are more steps involved. Also having issues getting parameters to work with Oracle queries.
Even though I am a big fan of SSIS, I would go with SSRS in this scenario.
Your requirement is that you simply need data in an Excel file. Though both SSIS and SSRS can do this task. SSRS has slight advantage in what you are trying to achieve.
You can format the Excel file in SSRS report however you would like to.
Similar to SSIS package that is easy to configure, SSRS also has easier development process. You can design and populate however you would like.
SSIS requires a SQL job to schedule it in order to run the package and then send you the Excel file or save it to some location. However in SSRS, you can simply create a subscription and export the Excel file to particular folder or send it to you in an email.
If you ever want to change the file export format, SSRS already does that for you.
Some of the points that I could think of.
This isn't a report, so don't use Reporting Services.
The SSIS package necessary for this is a single Data Flow task with two components: an "OLE DB Source" for your Oracle query, and an "Excel Destination". Draw a connection between the two components, configure them, press F5 and you're done.
Almost any property in SSIS can be set to the value of an expression. This includes the "ExcelFilePath" property of the Excel Connection Manager. Simply set that to an expression that appends the date to the file path, and you'll be set as long as you only run the package daily.
If you need to run it more than once a day, then simply precede the Data Flow task with a File System task to delete any previous version of the file.
Just tried this quickly myself and found one small issue. The data source I used included VARCHAR columns. The Excel Destination wanted Unicode, so I had to place a Data Conversion component between source and destination.
This link has a nice evaluation of the case you are presenting:
http://theruntime.com/blogs/gscarfone/archive/2009/07/15/data-dump-to-excel-through-ssis-and-ssrs.aspx
Basically it depends on your particular scenerio.
Hope it helps...

How can I allow users to switch data sources for an SSRS report?

I have two SQL Server databases with identical schemas, but different data. I also have SSRS generating reports, in native mode, for one of the databases. All reports the same shared data source.
I would like to allow users to get reports for the other database. I created a second shared data source for the second database. Modifying the reports to use this second data source results in reports as expected.
Because the RDLs are the same, except for the data source, and because I don't want to maintain what are basically duplicate reports, I'm looking for a way to dynamically switch data sources, depending on user input.
Is there an easy means of accomplishing this? An existing solution would be best. Barring that, can the RDL's data source be parametrized? Or, can the RDS's connection string be parametrized?
You can use parameters or other expressions in the connection string.
See http://msdn.microsoft.com/en-us/library/ms156450%28SQL.90%29.aspx (2005)
or http://msdn.microsoft.com/en-us/library/ms156450.aspx (2008)
I'm going to piggy back on the last answer. Yes, use parameters in the connection string, but populate the data to ensure your users aren't seeing database names, etc. that you might not want them to see for security. You can store the values in a table, pass both the human readable and SQL Server specific values.
Does that make sense?

Can I pre-process data before passing it off to SSRS 2005?

We are considering migrating to Sql Server 2005 Reporting Services. Many of our existing reports require pre-processing of the data before rendering it.
For example, we have a query for a report that returns GPS coordinates (Latitude and Longitude) from a stored procedure, but before passing off the DataSet to our reporting engine (currently Crystal) we call out to a Web Service to reverse geocode the coordinates and get an address string. We push this into the DataSet object.
I've read a bit about Data Processing extensions but I'm not sure that's what I want, as then (if I understand correctly) I would need to implement the entire processing flow (including retrieving the data from the stored proc) just to massage it a bit at the end.
How can I interject and pre-process the dataset after retrieving it from the data source, but before passing it on to the renderer?
You could create a .NET assembly with a method in it that processes an individual record. Then, include that assembly in the report, and call that method when each row is being rendered. This would do the processing and display the result.
For instance, after creating the assembly and adding it to the report, you could have a table where one of the cell expressions looks like this:
=Code.ReverseGeocode(Fields!Latitude, Fields!Longitude)
See http://msdn.microsoft.com/en-us/library/ms155798.aspx for some guidance.
You can also use the results of an SSIS package as a data source (the package is executed on demand when the report runs).
This can be very helpful if you are trying to solve the problem of joining data from multiple data sources into a single dataset for example: a geocode web service and a relational result set.
I don't think a lot of people realize that this exists and how useful it is for handling EII type reports
One option would be to use a ReportViewer control in local mode.
The data is loaded into ASP-NET, you can the pre-process it, then pass it to the control for presentation.
I'm not sure of how SSRS would deal with custom code/DLL when you want to process all data before thinking about presentation (as in the =Code.ReverseGeocode solution mentioned). RBAR feels wrong at the text box or cell level.
I guess I don't understand why you just don't write the SQl to provide the data the way you want it. Can't you calculate the field through a function or use a where clause to filter the data further. You can do quite extensive data manipulation in a stored proc or query data source.