Closed Thread
Results 1 to 3 of 3

Thread: Stored Procedure Parameter

  1. #1
    rvr707 is offline Newbie
    Join Date
    Nov 2009
    Posts
    6
    Rep Power
    0

    Stored Procedure Parameter

    Please help me with my sproc. I have this code:

    Code:
    ALTER PROCEDURE [dbo].[Sales by CustSummary]
    	@code varchar(500),
    	@fromdate date,
    	@todate date	
    AS
    BEGIN
    	SET NOCOUNT ON;
    
    	SELECT [Sales].[TransDate],[Sales].[StoreCode],[Branch].[Description],
    	[Sales].[Product ID], [Sales].[Units],[Sales].[Price]
    	FROM [Sales],[ Branch]
    
    	WHERE 	[Sales].[StoreCode]=[Branch].[StoreCode]
    	and [Sales].[StoreCode] in (@code)
    	and [TransDate] between @fromdate and @todate
    END
    But then nothing is retrieved. I have read in an article that this is not the right way to pass @code with IN. But I don't know how to correct this.

    @code has multiple items thats why i cant use =(equals) or assign.

    I hope you can help me. Thnx!

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Stored Procedure Parameter

    Try this (untested):
    Code:
    ALTER PROCEDURE [dbo].[Sales by CustSummary]
    	(@code varchar(500),
    	@fromdate date,
    	@todate date	)
    AS
    BEGIN
    	SET NOCOUNT ON;
    
    	SELECT [Sales].[TransDate],[Sales].[StoreCode],[Branch].[Description],
    	[Sales].[Product ID], [Sales].[Units],[Sales].[Price]
    	FROM [Sales],[ Branch]
    
    	WHERE 	[Sales].[StoreCode]=[Branch].[StoreCode]
    	and [Sales].[StoreCode] in (@code)
    	and [TransDate] between @fromdate and @todate
    END
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    rvr707 is offline Newbie
    Join Date
    Nov 2009
    Posts
    6
    Rep Power
    0

    Re: Stored Procedure Parameter

    its not valid in ms sql server declaration...

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. MASM Procedure help
    By Slider in forum Assembly
    Replies: 4
    Last Post: 01-29-2011, 04:55 PM
  2. Remove this Stored Procedure
    By BlaineSch in forum Database & Database Programming
    Replies: 5
    Last Post: 01-17-2011, 02:49 PM
  3. parameter input at program running(c:/file.exe -parameter)
    By granitt in forum Visual Basic Programming
    Replies: 1
    Last Post: 01-09-2009, 09:05 AM
  4. SQL Triggers and Stored Procedures
    By Amy in forum Database & Database Programming
    Replies: 7
    Last Post: 12-18-2008, 01:41 AM
  5. writing stored procedure in mysql
    By Orjan in forum Database & Database Programming
    Replies: 2
    Last Post: 03-25-2008, 01:26 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts