SSRS report not displaying data - sql

I have just created an SQL Server 2005 SSRS report and the data is not being displayed in the Preview pane.
The dataset is correctly populated from a stored procedure against a String parameter. I can execute it in the Data pane. When running the report in the Preview pane the correct number of rows are displayed but the contents of the cells do not contain any data
The source dataset is based on a Stored Procedure with a passed in String parameter in SQL Server 2005 that return the contents of a temp table. The dataset then maps the fields to locals. I can execute this correctly in teh Data view.
Stored Procedure
ALTER PROCEDURE spWebReportStage25BuildReview
#BuildNumber as nvarchar(50)
Temp table schema
CREATE TABLE #tmpModelZones
(
BuildID bigint NOT NULL,
BuildNo nvarchar(50) NOT NULL,
ModelID int NOT NULL,
ModelName nvarchar(50) NOT NULL,
ZoneID int NOT NULL,
ZoneName nvarchar(50) NOT NULL,
SortOrder int NOT NULL,
Created bit DEFAULT 0 NOT NULL,
Closed bit DEFAULT 0 NOT NULL,
PRIMARY KEY (BuildID, ZoneID)
)
SSRS Dataset
SSRS Dataset mapping
SSRS Dataset Parameter
Executing Dataset with parameter
There are no additional grouping, filters or aggregation on the displayed table. It is simply a flat table

Never seen this before. However, SSRS can be a bit "off" at times, so here's a list of things to try. I'm afraid most of these are of the type "Have you tried turning it off and on again?".
Delete the .data files associated with the report.
Duplicate/back-up the report, and try to add the dataset in a fresh, basic tablix to see if that does show data.
Check the hidden property. Don't forget that (for some stupid reason) it's not (like in any other sane product) a Visible Y/N field, but a Hidden Y/N field.
Double check font color and size, etc.
Run the report on your reportserver (as opposed to the preview) to check if that does work.
Use some temporary text boxes to show the actual values of your parameters, to check if they are exactly the same as when you test-run the data set.
Check the code-behind (xml in the rdl) for unexpected filters, hidden property, expressions, etc. in the tablix. Even if you can't quite "read" the RDL, with syntax highlighting you should be able to skim it and extract a lot of info on this.
Check the ExecutionLog2 and other logging stuff to see how many rows are being returned in report runs.
In addition, it would help if you update/edit your question with some more info:
What kind of groupings does the tablix have?
What are the filters on the tablix, row groups, and column groups?
What is the general structure of the dataset, and it's results?
How are the parameters structured and used?

When using temporary tables, SSRS fails to get the metadata. So there are basically 2 ways of letting SSRS know the column names:
Add SET FMTONLY ON. This will retrieve the metadata but it won't display the data.
Go to the DATA tab and click on the Generic query designer and click refresh fields. This will prompt a dialogue box for specifying the parameter value. When we run the query in query designer SSRS gets the schema and the data from the stored procedure. Now the data will be available in preview pane.

I also had a similar issue. In my case, it even occurred without any parameters or anything, just the most simple report you can imagine. It included a table with a single field, no filters were used. I did manage to view some data, but only those lines were shown which did not fit into the cell and thus forced the row height to increase.
My fix for this issue: changing the font or the font size from the standard (size 10, Segoe UI). Then, all data was showing. Changing this back to Segoe UI made the data disappear once again.

I had the same problem. Here is what I found. Here is my code:
DECLARE #tblPigProblems TABLE (
Id INT IDENTITY,
PPId INT,
GaugeColor VARCHAR(25),
FullStartTime VARCHAR(25),
PigSystem VARCHAR(25)
)
IF (1 = 0)
BEGIN
SELECT * FROM #tblPigProblems
END
...
SELECT '#tblPigProblems' [PigProblems],
#p_vchLine [Line],
GaugeColor [Product],
FullStartTime [Start Time],
PigSystem [Pig System]
FROM #tblPigProblems
What I did was to use the initial "SELECT * FROM #tblPigProblems" to ensure that if any error messages were specified in the code before the final select statement returning the dataset, that SSRS was able to determine the fields from the stored procedure. Then, when the results were determined, I assigned an alias to the fields. The problem was that the aliases for the fields did not match the declared field names (ie: the declared field "GaugeColor" did not match the alias "[Product]" I supplied in the select to create the result set. The way that I realized this is that when I refreshed the fields in the Data section of the SSRS report, then displayed the dataset fields, it listed the field names from the table declaration (ie: "GaugeColor"). When I executed the stored procedure within the dataset (clicked on the !), the result set listed in SSRS showed the field aliases (ie: "Product"). Since these didn't match, nothing was displayed in the textbox I had assigned the field to (ie: "=Fields!ColorGauge.Value"). SSRS did not pick up this discrepancy and allowed the report to be created, but no values to be displayed. The fix was simple, replace:
IF (1 = 0)
BEGIN
SELECT * FROM #tblPigProblems
END
with:
IF (1 = 0)
BEGIN
SELECT '#tblPigProblems' [PigProblems],
#p_vchLine [Line],
GaugeColor [Product],
FullStartTime [Start Time],
PigSystem [Pig System]
FROM #tblPigProblems
END
Dan

I had a case where a working report stopped displaying data. I added another table with no formatting, linked to same dataset - verified that the query no longer returned data when passed parameters by SSRS. After investigating, I noticed that my test parameter for a "anchor date" value was formatted as YYYY-MM-DD, and in my updated query, I was making assumptions about the order of the characters in the date parameter (to truncate to YYYY-MM for one join).
I suspected that SSRS may be passing the date in a different format (MM/DD/YY being my current cultural setting for date defaults). So running with that hunch, I changed my SQL logic to work with any date format passed. - e.g. left(convert(date, #anchorDate, 20), 7)
This fixed my problem - the format assumptions that I had tested with (hard coded values to test the query while developing) were bad assumptions. SSRS can pass data in local formats as well - so be sure to watch out for this kind of assumption.

I had the same problem and I tried to check the priorities of my tablix. I solved the problem by changing CANGROW value to FALSE.

Related

SQL Query result and SSRS result dont match

I have created a SQL that can pass in multiple parameters and more than one condition.
Example
SELECT *
FROM movement
WHERE Arrivalid IN (#ArrivalID) OR DepartureID IN (#DepartureID)
With this script, SELECT * FROM movement WHERE Arrivalid IN ('A_1234') OR DepartureID IN (''), i am able to pull out record from SSMS.
However, when I run it in SSRS, SSRS return me empty record.
Btw, the query is created as Dataset in SSRS.
Is it a must to pass in 2 parameters? But I have already set "allow blank value ("")".
Report Parameter Properties1: https://i.stack.imgur.com/9AJwO.png
There is no filter created on this simple table format.
SSRS Report
Does anyone have any idea what has gone wrong with my SSRS setup?
To add on:
In Dataset properties, i have added "Spilt" for multiple parameter.
Expression for parameter
Setting for Default Values
Parameters - Default Value
Assuming you want to be able to enter either arrival or departure IDs then you should be able to just do this...
SELECT *
FROM movement
WHERE (Arrivalid IN (#ArrivalID) OR #ArrivalID IS NULL)
OR (DepartureID IN (#DepartureID) OR #DepartureID IS NULL)
Try setting default value for that parameter:

Saving individual fields in SQL Server database table that doesnt allow null values

I am writing an app that has a large form process.
Because of it's size I want to be able to individually save a copy of each field into the database as it is entered in.
The problem is, my table designs don't allow for null values. So how can I create a new table row with a primary key without filling out all fields?
My main table that all other tables that link to contains a draft boolean flag. Once a draft form is filled out, it can be submitted and saved as a finished form.
My current logic would be to have placeholder values that are only acceptable in the draft flagged form e.g -1 for integers, -1 for string etc. But on completion and submission of the form, it will confirm that no empty -1 placeholders still exist before being used as a submitted form.
This seems really dirty though.
Has anyone else had a similar issue and what did they do to resolve it? I would prefer not to allow NULL values into my tables.
Thanks in advance,
use a 'staging' table to handle temporary/half filled form data.
when the user gets to the end then you will trigger the copy of the data from staging to the final table making all the needed checks/validation/whatever before putting the data in the real table.
the advantages i see:
your final table will not allow null
your final table will contain only valid data and no draft data (no need to check for placeholder once the data is in the final table)
your staging table will likely contain a small number of rows so the operations on that table should not add such a load on the system (to be checked in advance!!!)
if you require a login on your site/app then you can allow the user to get back later to complete the form
YMMV but this is a solution that worked fine form me and i really appreciate advantages 1 and 2. I don't like nullable fields because it happens that if null is allowed then it is null quite often and also don't like to mix temporary and final data if i can avoid it ^^
Your best option would be to save the user inputs as variables until all the form data has been received. At that point, you can safely insert the new row as a single insert using all of those variables without worrying about null values.
Additionally, using a single insert would reduce the overhead of several unnecessary db queries.
You can use default values for those columns which you want to save if no value will be given for those column default value set for those column will be inserted.But be sure to update all these columns because it will show default data when you will get data from db.
CREATE TABLE [dbo].[TestTable] (
[Id] INT NOT NULL,
[Category] VARCHAR (50) NOT NULL DEFAULT 'Default Value',
PRIMARY KEY CLUSTERED ([Id] ASC)
)

Why can't Aggregate and lookup functions be used in query parameter expressions in SSRS?

I'm using an if to run one query if the user selects all from a multivalued parameter, and the other if not. So I figured I'd compare selected parameters vs rows in the data set.
However I get this error:
“The expression used for the parameter 'DataSet2' in the dataset
'DataSet2' includes an aggregate or lookup function. Aggregate and
lookup functions cannot be used in query parameter expressions.”
Here's the part giving the issue:
IIf(Parameters!SomeOptions.Count < COUNTROWS("SOME_LIST"), ….
Of course supplementing the COUNTROWS("SOME_LIST") with 15 (the value it returns)works fine.
Anyone know why this happens, and/or any work around?
Here's a workaround I use in the absence of an IsSelectAll flag:
Add another internal parameter called InternalParameter_SomeOptions.
Set the default value and available values to equal the same data set as SomeOptions.
Set your expression to =IIF(Parameters!SomeOptions.Count <> Parameters!InternalParameter_SomeOptions.Count, nothing, Join(Parameters!SomeOptions.Value, "|"))
If you have a multi-selection parameter whose data source is a dataset and you want to know if ALL was checked, from within your REPORT Dataset (like an SQL) to filter properly, look no further!
Why does this matter? Say you have a dataset (love datasets as data source for parameters btw, save em on the server for reuse over and over) for displaying a vendor list for users to select one or more (multi) from. What if that list is 10,000 long. You do NOT want to use: WHERE VENDOR_ID IN(#VENDOR). If the list is long enough, it WILL bomb and you will have to hunt the error down in SSRS log. So, this is one reason why we need to check if ALL was selected.
Create a new parameter identical to the dataset parameter(so they both use the same dataset and have the same default values), make sure to set it to multi selection and hidden (you do not want users seeing it). I name mine ---All where --- is the name of my parameter to easily distinguish.
For the dataset that serves as your REPORT data, add an additional Parameter. I like to call it #Is----AllChecked where ---- is the name of my parameter. It is named as a boolean (1 for true, 0 for false). In this example, it would be named #IsVendorAllChecked.
In the DEFAULT value expression check if the count of each REPORT parameter is the same (the one the users use and the duplicate), and return a value, like 1 if the same 0 if not. For example =IIF(Parameters!Vendor.Count = Parameters!VendorAll.Count, 1, 0)
In your REPORT Dataset, evaluate the parameter value and act accordingly in your SQL: where ( (#IsVendorAllChecked = 1 and vendor_id = vendor_id) or (#IsVendorAllChecked = 0 and vendor_id in(#Vendor)))
#Vendor obviously being the parameter the user interacts.
Always wanted to contribute.
SE: Report Builder check if all was selected
SE: Report Builder how to check if all was selected
SE: Report Builder parameter query expression cannot use aggregates

Edit Parameter Field Crystal reports with NOT value?

In Crystal Reports, I want to add a WHERE field <> date to filter out dates that have a NULL value from my database in my report.
I'm using a legacy FoxPro database on the backend which generates an SQL statement from my report, but doesn't appear to have anyway of adding a WHERE clause to the generated statement.
When accessing the FoxPro backend directly, dates with psudo-NULL values have a date of 1899-12-30, but when they are pulled from FoxPro through Crystal they appear as 12/30/99 (which is maybe the same date just displayed in MM/DD/YY format).
I noticed that the report had an existing Parameter Field that prompts the user to filter out the original query down to a specific date range. I tried to add my own in addition to the Parameter Field, but discovered that what I needed with my WHERE field <> date is not an available option since there are only 3 types of Field Parameters mainly:
Discrete
Accept single and discrete values.
Ranged
Accept a lower and upper value in order to select everything in this range.
Discrete and Ranged
A combination of the two above
None of these appear able to filter the results of the query using a WHERE NOT type of clause, is there some other way to do this?
Add this to your record-selection formula:
// remove actual nulls
AND Not(Isnull({table.date_field}))
// remove old dates
AND {table.field} <> date(1899,12,30)
// remove dates not in select parameter value
AND {table.field} IN {#date_parameter}
All I really needed to do was add some criteria to the WHERE clause of the SQL statement, simple enough in an SQL client, but when you're doing this in Crystal Reports v10 it's a bit difficult to find, unless you know what you are looking for...
So what I needed to do was:
Select the field to filter by in the report (in the Details section)
Click the Select Expert button on the Experts toolbar.
In the Select Expert dialog the name of your field should appear in a tab.
Below you can select the WHERE criteria used to filter the records.

Dynamic SSRS report

I had a problem in creating the Dynamic report in SSRS. My problem is:
In a table I have stored SQL scripts with the column SQLScripts. If you execute these SQL scripts you get different number of columns for each script.
My problem is, I have one report with buttons of these scripts, for example test1, test2...like that. If you press test1 button this should take the test one SQL script and should display the report with appropiate columns in that sqlscripts.
I can't create individual reports for each test report, they are plenty. Are there any options for me to solve this problem...
The only way I've been able to get this to work sofar is:
Each report has 2 datasets.
ReportData
DataHeaders
The "DataHeaders" need to have the proper name of the datafields in "ReportData". Be careful since SSRS replaces blanks and special characters with "_"
Now, create a table (or matrix) and drag the DataHeaders as the Columns of your report. (This should be a grouped column). If you run it at this point, you'll see all your columns without any data. Now comes the magic:
Create another report that takes a "DataField" parameter. Create another table or matrix within this report and set it's dataset property to be "ReportData". In the DATA cell for the table, set it to the expression =Fields(Parameters!DataField.Value).Value
Now go back to your first report. Right click and insert a subreport. Right click on the subreport and select "Subreport Properties". Under general, select the second report you created to be used as the subreport. Under parameters, select the DataField parameter and set its value to something like =Fields!DataField.Value
In my case I did some formatting in this expression to fix the above mentioned issue with spaces and special characters, since my stored procedure was initially used in ASP.NET and this was just a proof of concept.
Also in my experience the performance isn't great. In fact it was kinda slow, though I haven't had a chance to switch it to use a shared dataset, which I suspect would help a bit. Please let me know if you find a better solution.
I have not found a way to do this completely dynamically. Here is a similar question with some possible solutions:
How do i represent an unknown number of columns in SSRS?
You basically need to create a 'master dataset' from the other Datasets that are based on your multitude of SQL scripts first.The master dataset should contain the data to be presented in it's most simplistic form, i.e. in a simple list format.
Finally, go to the toolbar in SSRS and drag a 'Matrix' into the report. A Matrix table acts similar to a pivot table in Excel or a CrossTab query in Access that will display whatever's in the Dataset.