t-sql 2008 pass parameter values

Answered t-sql 2008 pass parameter values

  • Sunday, January 06, 2013 10:45 PM
     
     

    In need to pass 5 parameters to a stored procedure in sql server 2008 standard edityion database. The 5 parameters come from a filename in a Visual Basic.Net 2010/2012 application. Two of the parameters are ok since they are numeric values however 3 of the parameters are character that translates to varchar values.
    My problem is the fields that are: 1. major product name, 2. sub product name, and 3. customer name may not be the exact values that are actually contained within the database. There may be differences in the values like upper versus lower case, the number of spaces that are entered between words, words like incorporated may have the abbreviation, and other any special circumstances.

    Between the 4 of the 5 parameters that are to be supplied to the stored procdure, I obtain distinct (unique) values for rows in the database.

    The only thing I think I can do is to look of names in character fields for the minimum size value contained in those columns. Thus my question is how would you write the queries to obtain the values I can referring to?

All Replies

  • Monday, January 07, 2013 12:46 AM
    Moderator
     
     Answered

    >upper versus lower case

    Use the UPPER function when comparing.

    >the number of spaces that are entered between words,

    Reduce it to single space:

    http://www.sqlusa.com/bestpractices2005/removemultiplespaces/

    >words like incorporated may have the abbreviation

    Build a synonym lookup table.


    Kalman Toth SQL 2008 GRAND SLAM
    New Book: Pass SQL Exam 70-461 & Job Interview: Programming SQL Server 2012

  • Monday, January 07, 2013 3:25 AM
     
     

    What you suggested is a good idea. However, what should I do when there are unexpected situations?

  • Monday, January 07, 2013 4:35 AM
     
     Answered

    I would suggested to create a mapping table in the database like this

    Name coming from application, Name in the database.

    Bcd, BCD

    Abc, A B C

    Then you can lookup "Abc" and get "A B C" and pass that value to the stored procedure.

    Regards,Eshwar.


    Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.

    • Marked As Answer by jazz_dog Monday, January 07, 2013 3:11 PM
    •