• shravan.gavva (11/20/2013)


    Hi,

    I have two columns in the same table

    One is data_value (varchar) and the other is sql_data_type (varchar). Data_value holds info like dates, decimals, etc..

    sql_data_type holds info about what type of data should be stored in data_value. How can i write a code so that specific_data_type goes into data_value as mentioned in sql_data_type???

    Thank you

    gs

    There is one and only one right way to deal with this. Drop the idea of using varchar to hold all kinds of datatypes. Use datetime and decimal datatypes to hold that kind of data.

    Something tells me you are working on creating an EAV system?

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/