Why is SQL Server procedure not executing properly?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahulae
    New Member
    • Jul 2008
    • 29

    Why is SQL Server procedure not executing properly?

    i'm trying to execute a procedure that should return a property that are available in a state within a price range(between x and y)

    i have written a procedure but not able 2 execute it properly
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    More details please.

    Sample data of your source table and the value/format of your desired output.

    -- CK

    Comment

    • rahulae
      New Member
      • Jul 2008
      • 29

      #3
      Given a valid character state and price range( between x and y) the system should be able to report all the properties that are available in that state with in that range with their asking price.

      Table:Attribute s(property_id,p roperty_name,as king_price,stat us,total_size,a ddress,city,sta te)

      Comment

      • Delerna
        Recognized Expert Top Contributor
        • Jan 2008
        • 1134

        #4
        [code=sql]
        SELECT Property_ID,Pro perty_Name,Aski ng_Price,Status ,
        Total_Size,Addr ess,City,State
        FROM Attributes
        WHERE State=@State
        AND Asking_Price BETWEEN @X AND @Y
        [/code]

        Comment

        • rahulae
          New Member
          • Jul 2008
          • 29

          #5
          i have to write a procedure for that and also tell me how to execute the procedure since we have to use a between operator

          Comment

          • Delerna
            Recognized Expert Top Contributor
            • Jan 2008
            • 1134

            #6
            The stored proc will look something like
            [code=sql]
            create proc GetAttributeRan ge
            @State varchar(20),
            @X decimal(18,2),
            @Y decimal(18,2)
            as
            SELECT Property_ID,Pro perty_Name,Aski ng_Price,Status ,
            Total_Size,Addr ess,City,State
            FROM Attributes
            WHERE State=@State
            AND Asking_Price BETWEEN @X AND @Y
            Go
            [/code]

            and you will call it something like this
            [code=sql]
            exec GetAttributeRan ge 'NSW',1.42,100. 30
            [/code]

            Comment

            • rahulae
              New Member
              • Jul 2008
              • 29

              #7
              Its working fine for me

              Thank You.

              Comment

              Working...