Arun, Here's how I'd do it in VB: cWhereStmt = " " If cItemNumber <> " " then cWhereStmt = cWhereStmt & " ItemNumber = " & cItemNumber & " and " End If If cDescription <> " " then cWhereStmt = cWhereStmt & " Item Description Like " & cItemDescription & " and " End If If cUM <> " " then cWhereStmt = cWhereStmt & " UnitMeas = " & cUM & " and " End If << insert code to remove the last -and- >> If cWhereStmt <> " " then cWhereStmt = "Where " & cWhereStmt End If cSelect Stmt = "Select fielda, fieldb From file1 " & cWhereStmt & " Order by 1,2 "
Bill > In this case the user can run a query on the VB application which will inturn call my stored procedure with different selection criteria. May be they key in all the criteria such as item number, description, unit of meassure etc ..... or in other case they may give one or more of these selection criteria. In this circumstance how do I build the SQL statement.