Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2006, 05:15 PM
Registered User
 
Join Date: Feb 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reporting Services - Return Null using '%'

When selecting % from one of my report parameters, null fields are not returned

An example of one of the datasets for the report parameter:

SELECT Display AS PlansAdmin
FROM LUGenInfoPlansAdmin
WHERE Display IS NOT NULL
UNION
SELECT '%' AS PlansAdmin
ORDER BY PlansAdmin

The WHERE clause of my result set
WHERE (Projects.WMPlansAdmin LIKE @PlansAdmin)

My question is, can I dynamically change the where clause to include NULLS
(Projects.WMPlansAdmin LIKE @PlansAdmin OR Projects.WMPlansAdmin IS NULL)
when users select the '%' parameter?

I've tried setting the where clause as a variable, but this gives me a syntax error:
DECLARE @WhereClause VARCHAR(100)
  IF (@Display = '%')
     SET @WhereClause = '@Projects.WMPlansAdmin LIKE ' + @Display + ' OR Projects.WMPlansAdmin IS NULL'
  ELSE
     SET @WhereClause = '@Projects.WMPlansAdmin LIKE ' + @Display

SELECT ...
FROM ...
WHERE @WhereClause


..any suggestions?



 
Old May 26th, 2006, 10:36 AM
Registered User
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Any luck with this? I have the same issue.

I know I can do this but I want to have multiple parameters.

IF @code is null
  BEGIN
    'sql without the where for the cust code
  END
ELSE
  BEGIN
    'sql with the where for the cust code
  END




 
Old May 26th, 2006, 11:05 AM
Registered User
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default


This solves the problem:

WHERE (isnull(wbw_line.CUST_CODE,'') LIKE @code)






Similar Threads
Thread Thread Starter Forum Replies Last Post
New to Reporting Services, please help cmreis BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 December 30th, 2005 02:07 AM
Reporting Services mikerowe SQL Server 2000 0 May 22nd, 2005 08:22 PM
Reporting Services Ben SQL Server 2000 3 February 8th, 2005 10:16 AM
reporting services Vrylle BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 August 6th, 2004 12:50 AM
reporting services msrnivas .NET Web Services 0 June 18th, 2004 04:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.