Is it possible to display the result of complex query in SSRS 2012? - visual-studio-2010

I'm new in SSRS and I want to know if it's possible to display a result of a complex query (which run perfectly on SSMS) in my report?
The problem is that I have an Over statement in my Query:
LEAD(Flow.MeasurementDate) OVER (Partition by
ComponentId, NominationCycle, LocationType, Frequency, FlowTypeId, UnitofMeasurement
ORDER BY MeasurementDate) nextMeasurement,
MAX(Flow.MeasurementDate) OVER (PARTITION BY
ComponentId, NominationCycle, LocationType, Frequency, FlowTypeId, UnitofMeasurement
) maxMeasurement
The error message is:
The OVER SQL construct or statement is not supported.
If it's possible please give me few steps to achieve this.

The Over construct is not supported by the SSRS query designer but the report should still work when the SQL is sent to Sql Server for processing.
If it doesn't, check that your database isn't running in a compatibility level where the Over construct is unsupported (80 or earlier).
If all else fails, an alternative is to put your query in a stored procedure and call that from SSRS.

That's just what SSRS is used for in general.
The steps are the same, no matter if it's a simple or complex query.
You use your query to fill a dataset and display this in a table on your report.
What you need is just a basic SSRS tutorial as it can be found here:
http://msdn.microsoft.com/en-us/library/ms167305.aspx

Related

Executing DAX query via .NET Core AdomdConnection returns null

I have a very simple DAX query which I can execute via SSMS with no problems.
As show above, the query returns 2 rows, one from the dynamic expression and one hardcoded "123".
When executed via C# Microsoft.AnalysisServices.AdomdClient, the hardcoded "123" row value is returned (oddly the ordinal position of rows does not match the execution in SSMS), but the dynamic expression row value is always null. This issue does seem to be isolated to the tables of this model as querying brand new "AdventureWorks" model programmatically does return values for dynamic expressions as well.
I am at a loss of what to explore next and I don't have high familiarity with querying Analysis Services programmatically, so any help would or hints what to try would be much appreciated.

Oracle In Clause not working when using Parameter

I have a Pesky SSRS report Problem where in the main query of my report has a condition that can have more than 1000 choices and when user selects all it will fail as my backend database is Oracle. I have done some research and found a solution that would work.
Solution is
re-writing the in clause something like this
(1,ColumnName) in ((1,Searchitem1),(1,SearchItem2))
this will work however when I do this
(1,ColumnName) in ((1,:assignedValue))
and pass just one value it works. But when I pass more than one value it fails and gives me ORA-01722: Invalid number error
I have tried multiple combination of the same in clause but nothing is working
any help is appreciated...
Wild guess: your :assignedValue is a comma-separated list of numbers, and Oracle tries to parse it as a single number.
Passing multiple values as a single value for an IN query is (almost) never a good idea - either you have to use string concatenation (prone to SQL injection and terrible performance), or you have to have a fixed number of arguments to IN (which generally is not what you want).
I'd suggest you
INSERT your search items into a temporary table
use a JOIN with this search table in your SELECT

How to make Oracle 'order by' behave like SQLServer?

i'm trying to write an Oracle query that sorts the results in the same way as MS SQL Server does. I'm toying with the 'NLSSORT' function and it's parameters but i can't get exactly the same results as what i can see with MS SQL Server.
The context is a generic data collection system that supports both Oracle and MS SQL Server. This is a pretty old system that is still under maintenance and development. No entity framework or any recent approaches to handle database interactions.
With a simple order by on MS SQL Server i get this result:
_TEST
04-00031-IPE
04-00044-OG
0A-A
A0-A
SAZ2217
The same query on Oracle returns this:
04-00031-IPE
04-00044-OG
0A-A
A0-A
SAZ2217
_TEST
I have tried many combinations of NLSSORT parameters without any success.
[edit]
By using the 'PUNCTUATION' NLS_SORT parameter value, i get results very close to the MS SQL sorting but there is still differences with substrings that contains sequences of numeric chars. Here is a sample query result:
Oracle
0031-CASTOR-BLOC1-AV-AP
0031-CASTOR-BLOC1-AV-SP
0031-CASTOR-BLOC1-SV-AP
0031-CASTOR-BLOC1-SV-SP
0031-CASTOR-BLOC10-DV-AP
0031-CASTOR-BLOC10-DV-SP
0031-CASTOR-BLOC2-DV-AP
Ms SQL
0031-CASTOR-BLOC10-DV-AP
0031-CASTOR-BLOC10-DV-SP
0031-CASTOR-BLOC1-AV-AP
0031-CASTOR-BLOC1-AV-SP
0031-CASTOR-BLOC1-SV-AP
0031-CASTOR-BLOC1-SV-SP
0031-CASTOR-BLOC2-DV-AP
Thank you for your help!
I finally found this solution:
ORDER BY NLSSORT(COLUMN_NAME, 'NLS_SORT = FRENCH_M')
At least in my particular context, i get the same sorting under both MS SQL Server (default sorting) and Oracle.
Here is two useful links:
http://www.myoracleguide.com/xl/Linguistic_Sorting_Frequently_Asked_Questions.htm
http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/ch5lingsort.htm#NLSPG005
Could consider use of rpad function?
e.g.
select name, rpad(upper(replace(translate(name,'_','+'),'-','') ),15,'0') as v1
from sorttest order by
rpad(upper(replace(translate(name,'_','+'),'-','') ),15,'0')

Using parameters in reports for VIsual Studio 2008

This is my first attempt to create a Visual Studio 2008 report using parameters. I have created the dataset and the report. If I run it with a hard-coded filter on a column the report runs fine. When I change the filter to '?' I keep getting this error:
No overload for method 'Fill' takes '1' argument
Obviously I am missing some way to connect the parameter on the dataset to a report parameter. I have defined a report parameter using the Report/Report Parameter screen. But how does that report parameter get tied to the dataset table parameter? Is there a special naming convention for the parameter?
I have Googled this a half dozen times and read the msdn documentation but the examples all seem to use a different approach (like creating a SQL query rather then a table based dataset) or entering the parameter name as "=Parameters!name.value" but I can't figure out where to do that. One msdn example suggestted I needed to create some C# code using a SetParameters() method to make the connection. Is that how it is done?
If anyone can recommend a good walk-through I'd appreciate it.
Edit:
After more reading it appears I don't need report parameters at all. I am simply trying to add a parameter to the database query. So I would create a text box on the form, get the user's input, then apply that parameter programmatically to the fill() argument list. The report parameter on the other hand is an ad-hoc value generally entered by a user that you want to appear on the report. But there is no relationship between report parameters and query/dataset parameters. Is that correct?
My last assumption appears to be correct. After 30 years in the industry my bias is to assume a report parameter actually filters the SQL data using the given parameter. This is not the case with .rdlc files used by Report Viewer. These report parameters have nothing to do with fetching data. Sounds like this was a design decision on Microsoft's part to completely separate the display of data from the fetching of data, hence, Report Viewer has no knowledge of how data may be fetched. Best way for me to conceptualize this dichotomy is to think of Report Parameters more as Report Labels, quite distinct from the dataset query parameters.

Using XQuery in Linq To SQL?

Let's say I have a table that has a column of XML type data. Within SQL, I can execute the following statement:
select top 10 *,
Content.value('(/root/item/value)[1]', 'float') as Value
from xmltabletest
where Content.value('(/root/item/MessageType)[1]', 'int') = 1
The result set contains only the records matching the criteria, and it extracts a value from the XML into a column called 'Value'. Nice and simple.
Can the same thing be achieved with Linq To SQL?
I'd like to get SQL to do the heavy lifting and only return data matching my criteria rather than having to select, transfer, and then process a potentially massive chunk of data. As far as I can tell this isn't possible at the moment, but I thought I should ask.
(The environment is .NET 3.5, VS2008, SQL Server 2005 if that helps)
I'm not exactly sure if this is out of date now, but according to Scott Guthrie XML datatypes are:
represented as strings in LINQ to SQL
Entities. You could use XLINQ to query
on an XML column within your LINQ to
SQL entitiy - but this querying would
happen in your middle-tier (within
ASP.NET). You can't execute a remote
XQuery against the database and filter
returned results based on that in the
first release.
So in answer to your question, I'd say "no."

Resources