Skip to content

SQL Server 2008 Filter Stored Procedure

David Smith

Asked Mar 3, 2012, 2:57 PM EST1 answer
Share
LinkedInX
Hey C sharp corner, Lets help me write this storep procedure. I am struggling with this one universe procedure I am trying to write. I am going to make an example up and we can build from there.

I am using SQL Server 2008, management studio.

There are three required filters and three optional filters.



Required Filters: When the user wants to select this information, they have to always, always, always select the required filters below.

ColorSerialNumber, ColorPartNumber,   ColorType,

Optional Filters: The user have the option to select the filters below. I am have rough time to incorporate the optional filters successfully in one procedure

ColorStartDateTimeRange, ColorDateEndTimeRange,   ColorTestPhase, and ColorIdentification.

I am going to start off the the stored procedure and then we begin from there. Lets begin. I will start the procedure in the next reply.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Ok lets begin, Here is the procedure I started off, lets incorpate all optional filters.


    Required Filters: When the user wants to select this information, they have to always, always, always select the required filters below.

    ColorSerialNumber, ColorPartNumber,   ColorType,

    Optional Filters: The user have the option to select the filters below. I am have rough time to incorporate the optional filters successfully in one procedure

    ColorStartDateTimeRange, ColorDateEndTimeRange,   ColorTestPhase, and ColorIdentification.


    CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName>
    (
         @colorSerialNumber VarChar(16),
         @colorPartNumber  VarChar(16),
          @colorType  VarChar(16)
         @ColorStartDateTimeRange VarChar(25),
        @ColorDateEndTimeRange   VarChar(25),   
        @ColorTestPhase 
    VarChar(16), 
       @ColorIdentification
    VarChar(16)
    )
    AS
    BEGIN

    SELECT ColorSerialNumber , ColorPartNumber  , ColorType  , ColorStartDateTimeRange, ColorDateEndTimeRange,   ColorTestPhase, ColorIdentification
    FROM Color Table
    Where  ColorSerialNumber = @colorSerialNumber  AND ColorPartNumber  = @colorPartNumber   AND ColorType  = @colorType 


    END
    GO
    0