locked
Procedure # Search criteria are 'Contains','Begin with','equal','not equal' and 'does not contain' RRS feed

  • Question

  • I have 2 search fields on screen

    CustomerName and Comments

    Search criteria are 'Contains','Begin with','equal','not equal' and 'does not contain' for both field

    Want to write a procedure to get the searched data.

    Please suggest the better way

    Thanks in advance

    Friday, August 3, 2012 8:39 AM

Answers

  • Hello,

    Please, could you provide more informations about your problem ?

    - the full version of your SQL Server Express ( 2005,2008,2008 R2,2012 + last installed service pack ). It would be useful as each new version is providing novelties in the syntax of the T-SQL ( Transact-SQL ) statements. If you have installed the edition with advanced services, could you tell us ?

    - the structure of the tables in which you are searching data ( the better way would be to provide the full CREATE TABLE statements, including primary/foreign keys and indexes as the use of indexes could give performance )

    - have you enabled the full-text search ? Is the Comments field using the FileStream feature ? 

    It is possible that , if your question or your table structure are a little complicated  , a moderator moves your thread towards the TRANSACT-SQL Forum. Only moderators can do this operation. It avoids to have to recreate a new thread, no lost posts and it will avoid to have a thread dying because it is not in the good forum ( i prefer to wait for the agreement of the original poster that's to say you Igseem before doing the move ) .

    We are waiting for your feedback to try to help you more efficiently.

    Have a nice day

    PS : i have choosen T-SQL for SQL Server 2008 R2 because it is the most common choice ( few differences with SQL Server 2008 and it is the beginning of SQL Server 2012 )

    for 'Contains' or 'Begin with :http://msdn.microsoft.com/en-us/library/ms179859(SQL.105).aspx

    for Comparison Operators http://msdn.microsoft.com/en-us/library/ms188074(SQL.105).aspx

    For the search of rows :http://msdn.microsoft.com/en-us/library/ms189499(SQL.105).aspx

    Maybe, these links could be a start to the creation of your SELECT statement 


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.


    • Edited by Papy Normand Friday, August 3, 2012 9:57 AM PS added
    • Proposed as answer by amber zhang Monday, August 6, 2012 2:24 AM
    • Marked as answer by amber zhang Monday, August 13, 2012 1:28 AM
    Friday, August 3, 2012 9:41 AM