Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Parameter problems

Parameter problems

Scheduled Pinned Locked Moved Database
sharepointdatabasehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shrimpersfan
    wrote on last edited by
    #1

    Hi there. I have the following stored procedure: /**********************************************/ CREATE PROCEDURE sp_iet_ComplaintReport @StartDate DATETIME, @EndDate DATETIME AS select co.ComplaintID, pli.Description AS RegardingDD, co.DateRaised, c._accCustomercode, rtrim(c.firstnames) + ', ' + rtrim(c.lastnames) as Name, CASE WHEN co.BeenRead = 0 THEN 'Open' WHEN co.BeenRead = 1 THEN 'Completed' END AS Status, rtrim(u.fullname) as handler from complaint co inner join contact c on co.contactid = c.contactid inner join adm_picklistitem pli on co.regardingdd = pli.localcode and pli.picklistname = 'complaintlist' left outer join adm_user u on co.handler = u.userid where co.dateraised >= @startdate and co.dateraised <= @enddate GO /*********************************************/ This works fine but i want to be able to pass @Handler and map that to the complaint.Handler field. The thing that i want is if i pass NULL to the @Handler then it should bring back all Complaint.Handlers but if you pass an actual value to @Handler then this should bring back a matching value (if it exists). Sorry if I have worded poorly. Any help would be greatly appreciated.

    M 1 Reply Last reply
    0
    • S Shrimpersfan

      Hi there. I have the following stored procedure: /**********************************************/ CREATE PROCEDURE sp_iet_ComplaintReport @StartDate DATETIME, @EndDate DATETIME AS select co.ComplaintID, pli.Description AS RegardingDD, co.DateRaised, c._accCustomercode, rtrim(c.firstnames) + ', ' + rtrim(c.lastnames) as Name, CASE WHEN co.BeenRead = 0 THEN 'Open' WHEN co.BeenRead = 1 THEN 'Completed' END AS Status, rtrim(u.fullname) as handler from complaint co inner join contact c on co.contactid = c.contactid inner join adm_picklistitem pli on co.regardingdd = pli.localcode and pli.picklistname = 'complaintlist' left outer join adm_user u on co.handler = u.userid where co.dateraised >= @startdate and co.dateraised <= @enddate GO /*********************************************/ This works fine but i want to be able to pass @Handler and map that to the complaint.Handler field. The thing that i want is if i pass NULL to the @Handler then it should bring back all Complaint.Handlers but if you pass an actual value to @Handler then this should bring back a matching value (if it exists). Sorry if I have worded poorly. Any help would be greatly appreciated.

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      In your where clause try the following Where (Isnull(@Handler,'') = '') or Handler = @Handler If the test for @handler = '' then no filter is applied, if @handler has a value then the filter is used. Caveat - many of these in a single query can reduce performance!

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups