You must Sign In to post a response.
  • Category: SQL Server

    Store Procedure problem

    i am jenerating reports on active forms using VS 2008 AND SQL 2005,the problem is i will select customercode and enquiryreiveddate between '20/4/2012' and '25/5/2012' ,some time i need to janarate by customercode only

    i need queries and store procedure
  • #690170

    CREATE PROC Search
    @CustomerID INT,
    @FromDate DATETIME,
    @ToDate DATETIME
    AS
    BEGIN
    IF @CustomerID <> '' THEN
    -- Write your query directly fetch from Customer code
    ELSE
    SELECT * FROM Table
    WHERE Date BETWEEN @FromDate AND @ToDate
    END

  • #690172
    i think me not posted my problem clearly ,i have to janerate report from both customercode(column1)=@customercode and date(column2) between '20/4/2012 and 25/5/2012 and some time i have to jenarate reports by customercode=@customercode only so if i am going to jenarate reports by customercode i will not select date, date column is one in the i am jenarating reports from this date to this

  • #690174
    1)i have to pass value to customercode(column1) and date(column2) between "" and ""
    or
    2)i have to pass value to customercode(column1) only
    need store procedure

  • #690175
    in my above example, if custcode is there it will not take any date.
    if u not giving id it will fire the second query

  • #690176
    Hi,

    For date column don't use "between and" instead use less than and greater than symbol like below,

    StartDate>= '01/01/2012' and EndDate<'31/12/2012'


    Regards,
    Asheej T K

  • #690181
    no no i have to show ex: customer code(customer code-001) have some enquiries assume 10 ,if i select customer code-001 then 10 enquiries will show ,now i have to select customer code and need to show those whom enquiries between 20/4/2012 and 25/5/2012 ,store procedure should work if select customer code and date between 20/4/2012 and 25/5/2012 or only by customer code


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.