You must Sign In to post a response.
  • Category: SQL Server

    Insert comma separated values into a single column

    Hi
    I want to insert comma separated values into a column in my table.
    I am using SSRS. There is a drop down menu with multilpe values.
    when the user selects multiple values, say 23,24,25 these values will be stored in the parameter and this parameter will be passed to an insert query.
    On execution the data in the column should look something like this

    suppose columnNo is one of the column in my table then,

    columnNo
    23,24,25

    But if i select single value like 23 or 24 i am able to insert but when i select multiple values i am not able to insert.
    How can i do this using sql server 2005.
    Any suggestions?
  • #460945
    Table1 has three attribute
    Synonymsid int is primary key
    Wordid is int
    SyWordid is nvarchar(100) // contain wordid with comma seperator


    When inserting value in SyWordid fetch its previous data in variable and append another wordid with comma seperator
    and then Update it.

    Eg:
    Synonymsid | Wordid | SyWordid
    1 | 12 | 13,14,25

    Regard's
    Rakesh Sharma, NEPL

  • #460990
    u can achive this thing in two way.
    first u just insert first 24 in col
    after than update same with other value which seprated with as
    update tblname set col = col + ',' +'25' where col = 24
    or u can use other approch for that
    first u get all value in a varible with comma(,) seprator and then finally insert it in to the table.

    Regards & thanks
    Arvind kumar
    Visit--blog.akumars.esoftera.in


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.