all groups > sql server reporting services > july 2005 >
You're in the

sql server reporting services

group:

SELECT TOP @variable


SELECT TOP @variable agenda9533
7/6/2005 1:14:02 PM
sql server reporting services:
I want to do something like this: SELECT TOP @variable .
I've read all related topics BUT I cannot use stored procedure for this
report, 'cause I do not have access to prod db, I'm just sending rdl for
upload. How to make it work on dataset level or through the report layout?

I know SQLServer doesn't recognize "Select Top @variable" statement.
SELECT top &variable, Ticket.problem AS Issue,
COUNT(Solutions.solution_date) AS [Tickets Touched]
FROM Ticket INNER JOIN
Solutions ON Ticket.ticket_number = Solutions.ticket_number
WHERE GROUP BY Ticket.problem

Or

SELECT Ticket.problem AS Issue, COUNT(Solutions.solution_date) AS [Tickets
Touched]
FROM Ticket INNER JOIN
Solutions ON Ticket.ticket_number = Solutions.ticket_number
WHERE GROUP BY Ticket.problem
HAVING (COUNT(Solutions.solution_date) > CAST(@num AS int)) doesn't work

Please, help![I]
RE: SELECT TOP @variable Gavin R
7/7/2005 4:25:02 AM
Hi,

You could use an expression in the dataset query window to define this SQL
statement

So, you could set your SQL up as something like :

="SELECT TOP " & Parameters!TopCount.Value & " FROM TableName"

So, you point your query directly to the Report Parameter. Note that you
will need to run the un parameterised query at least once to populate your
field list before you start parameterising in this way.

[quoted text, click to view]
Re: SELECT TOP @variable Oleg Yevteyev
7/11/2005 10:23:42 AM
You can do something like

--declare @variable int
--set @variable=3
set rowcount @variable

SELECT Ticket.problem AS Issue,
COUNT(Solutions.solution_date) AS [Tickets Touched]
FROM Ticket INNER JOIN
Solutions ON Ticket.ticket_number = Solutions.ticket_number
WHERE GROUP BY Ticket.problem

set rowcount 0

commented lines are for you to test.
just pass @variable as a report parameter



[quoted text, click to view]

Re: SELECT TOP @variable agenda9533
7/11/2005 1:23:02 PM
Thank you!
My own 5 cents...

This problem got resolved playing around report layout/group properties/filter
Expression: =count(Fields!ticket_number.Value)
Operator: TopN
Value: =Parameters!TopN.Value


Again, thank you!

[quoted text, click to view]
AddThis Social Bookmark Button