0% found this document useful (0 votes)
34 views

Select From Tablename Where (Case When @repparam 'All' and Colname @repparam Then 1 When @repparam 'All' Then 1 End) 1

This SQL query selects all columns from a table where either a column equals a parameter if it is not set to 'ALL' or returns all rows if the parameter is set to 'ALL'. It uses a CASE statement to check the parameter and column value, returning 1 if the condition is met to be included in the results.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Select From Tablename Where (Case When @repparam 'All' and Colname @repparam Then 1 When @repparam 'All' Then 1 End) 1

This SQL query selects all columns from a table where either a column equals a parameter if it is not set to 'ALL' or returns all rows if the parameter is set to 'ALL'. It uses a CASE statement to check the parameter and column value, returning 1 if the condition is met to be included in the results.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

SELECT * FROM TableName

WHERE
(
CASE
WHEN @RepParam <> 'ALL' AND ColName= @RepParam THEN 1
WHEN @RepParam= 'ALL' THEN 1
END
) = 1 ;
= javascript:void(window.open( http://myserver/mypath/myasppage.html , subreport ))

You might also like