How to show a dataset field in a single textbox ssrs - sql

I have created a dataset in SSRS which is hooked to a Stored procedure. The stored procedure resultset includes the following columns
OutputID, Timestamp, ProductName, Price, ProductNumber.
I show the above in a tablix in my report which works perfectly fine. I have about 10 rows.
The question I have is
I want a textbox on my report which will show productNumber as follows
1,2,3,4,5,6,7,8,9,10
I am fairly new to SSRS so forgive my ignorance.
The backend is SQL Server 2008 R2.

Try this in the textbox expression
=Join(LookupSet(1, 1, "FIELD NAME,"DATASETNAME"),",")
this will concatenate the result with comma

Related

how to pass a parameter in Crystal Reports?

I have a problem in Crystal reports 11. Because it has limitation to showing the information in dynamic reports and I have a huge list of customer, I want to write a query and ask the first letter of the customer name. If for example, it starts with A, just show the A customers.
this is my query:
select distinct bill_to_code
from TLORDER
where left(BILL_TO_CODE ,1 ) = ?
And CURRENT_STATUS <> 'CANCL'
AND LEFT(BILL_NUMBER , 1 ) NOT IN ('M','U','T','K')
but when I copy this to crystal reports and create a parameter , I get an error
Failed to retrieve data from the database
I should mention that I have another sql query in this report .
It is best to use Stored Procedure when trying to pass a parameter. How to create SP. Then used the SP for your report.

Dynamic SQL queries as parameter

I need a Report where a user has to choose 2 parameters. The first parameter contains the years (2017, 2016...), and the second one contains the ID process. Depending on the process that the user chooses, the SQL statement will be one or another. The parameter year is part of the WHERE clause of the SQL contained in the second parameter.
So I have this report with 2 parameters (param_year, Indicador). Query parameter is done using a table datasource, where the IDs column contains the SQL sentences and the Values column contains the text the user must select.
So what I'm doing next is to set ${Indicador} as the SQL statement in the JDBC connection that I have done to the Database. This is reporting me an SQL error
"Failed at query: ${Indicador}.
Any suggestions will be appreciated. Thanks in advance.
Another option is to create multiple datasources in your Master/sub report, then select appropriate datasource using PRD expression on Master/sub Report -> Attributes -> query -> name attribute.
More detailed explanation:
Create a query (I mean a query as a PRD object, which uses the PRD datasource) for every SQL string you need and move the SQL strings from the parameter table into Report Designer queries definitions.
Replace the SQL strings in your parameter table with names of corresponding queries, e.g:
Use the value of your parameter (which should be equal to the PRD query name) as value for Master/sub Report -> Attributes -> query -> name attribute:
You need Pentaho Data Integration to do this kind of dynamic query
If the table structure (output columns) for both queries is the same, you could put them together into one big SQL statement with UNION ALL and put in each query "WHERE ${Indicador} = ValueToRunThisQuery".
The optimizer should be smart enough to know the not-selected subquery is going to return zero rows and not even run it. You can supply a few null columns if one query has fewer columns, but the data types have to be the same for filled columns.
If the output table structure is different between the two queries they should be in different data sources, or even reports.
SELECT ID, BLA, BLA, BLA, ONLY_IN_A
FROM TABLE A
WHERE ${Indicador} = "S010"
UNION ALL
SELECT ID, BLA, BLA, BLA, NULL
FROM TABLE B
WHERE ${Indicador} = "S020"

Access form fields for multiple Query parameters

I am using Access 2013.
I have one table,A form and a query in database.
I am trying create query to filter data in table using form.
I have added two fields(combobox) in form.
Both are referencing different columns.
And a button to trigger.
I am using this formula in Query for 'where' clause for one field(in Query)
[Forms]![frmDataEntry]![Transaction Type] Or IsNull([Forms]![frmDataEntry]![Transaction Type])
Its working fine if I select any value, its showing data matching that value.It's showing all records when I leave it blank.
But its not working if I add same formula(changing fieldname) for other parameter too.
Its showing correct data, if I select values for both comboboxes in form.But its showing blank dataset, If I ignore any combo box.
My expectation is:
If I select both values......It should filter matching both and get result.
If I select none.............It should show all records.
If I select only one.........It should filter based on only that column.
You could use in your WHERE clause this
Like IIf(IsNull([Forms]![frmDataEntry]![Transaction Type]),"*" ,
[Forms]![frmDataEntry]![Transaction Type])

Using the Like '%" operator in the Sql Command Crystal Reports

I have a query to pull out data based on parameters, but now I have a problem using the Like '%' operator in the query, so that when I select data based on this parameter only data with the letters prefixed to this operator can be pulled.
Below is the query
select InventoryName,StockNumber,OBAL,RPO,XEFR,RDJ,RET,TSFR,ISS,PISS,ADJ,CBAL
from Transactions
where InventoryName LIKE 'se%' and ReportingPeriod ='January 2005'
order by InventoryName,StockNumber
For example, with this I am able to pull data which has SE of January 2005. It works fine in SQL 2005 but now I want to use it in Crystal report as a parameter to help pull out data based on the InventoryName chosen and the month and year. I am new to Crystal Reports.
As per my comment you may use the following :
where InventoryName LIKE #input + '%'
Use symbol '*' instead of '%'. I have encountered this problem also, sql requires '%' but CR requires '*', you can try simple example with CR designer, insert where clause in "RecordSelection".

How to insert a total column in a crosstab report in VS 2008

How to insert a total column in a crosstab (matrix) report in Report Designer in VS 2008?
It seems that i can only insert a subcolumn in a crosstab report.
Ok I got it now. I just right-clicked the column header and selected Subtotal.