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. Problem with Multiple search Stored Procedure

Problem with Multiple search Stored Procedure

Scheduled Pinned Locked Moved Database
databasehelpsharepoint
5 Posts 4 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.
  • R Offline
    R Offline
    reogeo2008
    wrote on last edited by
    #1

    Hi all, i was trying to do a mutiple select with following fileds ServiceCategoryName(field)->ServiceCategory(Table) ServiceName(field)->Service(Table) ServiceLocation(field)->Location(Table) Created Date,SendersName,SendersEmaild(fields) ->ServiceItemForward (Table) DB:SQLServer 2008 and the sp i wrote is following what changes should i make to this ALTER PROC [dbo].[usp__Search_ServiceItemForward] @CategoryID int, @ServiceID int, @LocationName varchar(100), @createdFromDate date, @createdToDate date, @sender varchar(100), @senderEmail varchar(100) AS if(@createdFromDate is null) set @createdFromDate =dateadd(d,-7, CONVERT(date, GETDATE())) if(@createdToDate is null) set @createdToDate=CONVERT(date, GETDATE()) Begin SET NOCOUNT ON SET XACT_ABORT ON BEGIN TRAN SELECT dbo.ServiceItemForward.* FROM dbo.ServiceItemForward INNER JOIN dbo.ServiceItems ON dbo.ServiceItemForward.ServiceItemID = dbo.ServiceItems.ServiceItemID INNER JOIN dbo.Service ON dbo.ServiceItems.ServiceID = dbo.Service.ServiceID INNER JOIN dbo.ServiceCategory ON dbo.Service.ServiceCategoryID = dbo.ServiceCategory.ServiceCategoryID where (@CategoryID=0 or ServiceCategory.ServiceCategoryID = @CategoryID) and (@ServiceID=0 or Service.ServiceID = @ServiceID) and (@LocationName=0 or ServiceItems.ServiceLocation = @LocationName) and (ServiceItemForward.CreatedDate Between @createdFromDate and @createdToDate) and(@sender is null or ServiceItemForward.SendersName=@sender) and (@senderEmail is null or ServiceItemForward.SendersEmaild=@senderEmail) COMMIT End please help me out in htis.... Thanks in advance

    M 1 Reply Last reply
    0
    • R reogeo2008

      Hi all, i was trying to do a mutiple select with following fileds ServiceCategoryName(field)->ServiceCategory(Table) ServiceName(field)->Service(Table) ServiceLocation(field)->Location(Table) Created Date,SendersName,SendersEmaild(fields) ->ServiceItemForward (Table) DB:SQLServer 2008 and the sp i wrote is following what changes should i make to this ALTER PROC [dbo].[usp__Search_ServiceItemForward] @CategoryID int, @ServiceID int, @LocationName varchar(100), @createdFromDate date, @createdToDate date, @sender varchar(100), @senderEmail varchar(100) AS if(@createdFromDate is null) set @createdFromDate =dateadd(d,-7, CONVERT(date, GETDATE())) if(@createdToDate is null) set @createdToDate=CONVERT(date, GETDATE()) Begin SET NOCOUNT ON SET XACT_ABORT ON BEGIN TRAN SELECT dbo.ServiceItemForward.* FROM dbo.ServiceItemForward INNER JOIN dbo.ServiceItems ON dbo.ServiceItemForward.ServiceItemID = dbo.ServiceItems.ServiceItemID INNER JOIN dbo.Service ON dbo.ServiceItems.ServiceID = dbo.Service.ServiceID INNER JOIN dbo.ServiceCategory ON dbo.Service.ServiceCategoryID = dbo.ServiceCategory.ServiceCategoryID where (@CategoryID=0 or ServiceCategory.ServiceCategoryID = @CategoryID) and (@ServiceID=0 or Service.ServiceID = @ServiceID) and (@LocationName=0 or ServiceItems.ServiceLocation = @LocationName) and (ServiceItemForward.CreatedDate Between @createdFromDate and @createdToDate) and(@sender is null or ServiceItemForward.SendersName=@sender) and (@senderEmail is null or ServiceItemForward.SendersEmaild=@senderEmail) COMMIT End please help me out in htis.... Thanks in advance

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

      You do realise in your null date test you are populating @createdToDate in both tests. It would help to know what the problem is!

      Never underestimate the power of human stupidity RAH

      R 1 Reply Last reply
      0
      • M Mycroft Holmes

        You do realise in your null date test you are populating @createdToDate in both tests. It would help to know what the problem is!

        Never underestimate the power of human stupidity RAH

        R Offline
        R Offline
        reogeo2008
        wrote on last edited by
        #3

        Hi, I have cooreected that statement and the code was not wrkng.....

        L 1 Reply Last reply
        0
        • R reogeo2008

          Hi, I have cooreected that statement and the code was not wrkng.....

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          reogeo2008 wrote:

          I have cooreected that statement and the code was not wrkng....

          If you post a problem, then describe what the code is supposed to do and what the error is. All we see is your code and the statement that it ain't workin', but you didn't explain what the desired result would be like or what you're trying to achieve. Why is there a commit, if you are only selecting records?

          Bastard Programmer from Hell :suss:

          S 1 Reply Last reply
          0
          • L Lost User

            reogeo2008 wrote:

            I have cooreected that statement and the code was not wrkng....

            If you post a problem, then describe what the code is supposed to do and what the error is. All we see is your code and the statement that it ain't workin', but you didn't explain what the desired result would be like or what you're trying to achieve. Why is there a commit, if you are only selecting records?

            Bastard Programmer from Hell :suss:

            S Offline
            S Offline
            SilimSayo
            wrote on last edited by
            #5

            Eddy Vluggen wrote:

            Why is there a commit, if you are only selecting records?

            Just to be sure that he is committed to selecting records only. Nothing else! :)

            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