Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2009
    Posts
    20

    Unanswered: Merging Fields puzzle

    I have a number of fields I am trying to merge into one. We are using a sql database where when a note is made on a record it records a record with a specific memo type and the time and date created.

    I am trying to create a field for each record ID where all of these record entries are grouped together to show in a view.

    The best way I can describe it would be if it was in excel =Memo1&Memo2&Etc.

    There is a row for each record so unsure how to achieve this.

  2. #2
    Join Date
    Mar 2007
    Location
    Holmestrand, Norway
    Posts
    332
    You can use + as string concatenation operator in T-SQL. You may need to cast or convert some columns to string (n)varchar data first.
    Ole Kristian Velstadbråten Bangås - Virinco - MSSQL.no - Facebook - Twitter

  3. #3
    Join Date
    Nov 2009
    Posts
    20
    Can I do that going down a column though? Sorry that wasn't clear in my first post now I have re read it. So I would be looking to do this

    Original Data

    ID Memo

    1 Text
    1 More Text
    1 Even More
    2 Test Data
    2 Data Test

    Result

    ID Memo

    1 Text - More Text - Even More
    2 Text Data - Data Test

  4. #4
    Join Date
    Mar 2007
    Location
    Holmestrand, Norway
    Posts
    332
    No, that was not what you asked for. What you want to look at is this post: Concatenating Row Values in SQL Server
    Ole Kristian Velstadbråten Bangås - Virinco - MSSQL.no - Facebook - Twitter

  5. #5
    Join Date
    Nov 2009
    Posts
    20
    Sorry I was confusing myself yesterday let alone anyone else, thanks I will take a look at that

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •