Home Forums SQL Server 2008 T-SQL (SS2K8) avoiding duplicates in comma separated values column RE: avoiding duplicates in comma separated values column

  • kalpit_yellow (4/18/2013)


    Hi,

    I am working on stored proc to update master table from temp table and getting following issue.

    temp_table

    sa, Logger, Reader

    master_table

    sa, Reader

    Reqired_Output_On_master_table

    sa, Reader, Logger

    So i only want to add comma seperated value when it is not already present in master table. (to avoid duplicate entry). i think i have to use CHARINDEX but don't know exact implementation. Any help from you guys will be gr8...

    Thanks,

    Hi and welcome to the forums. I would be happy to help but you haven't posted enough details for me to be able to offer much help. If you can post ddl, sample data and desired output I am certain we can figure this out pretty quickly. Please take a few minutes and read the article in my signature about best practices when posting questions.

    _______________________________________________________________

    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/