Adding text to a text column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Metalzed
    New Member
    • Sep 2006
    • 27

    Adding text to a text column

    Hi

    I want to have a log so in my table i got a TEXT field called LOGG. I want to update this field with new data by adding more text to field.

    I am using MS SQL

    'test' + 'test' doesn't work . say you cant add 2 text to each other

    concat('test',' test') doesn't work . say that CONCAT isn't a built in function


    this code works but is it really the best way to do? and how long can a varchar be?

    Code:
    UPDATE    GAMES
    SET LOGG =
    CAST(CAST(LOGG AS varchar(200)) + CAST('test' AS varchar(5)) AS text)
    
    WHERE     (ID = 21)
  • galexyus
    New Member
    • Sep 2006
    • 15

    #2
    Hey,

    Use this instead:
    Code:
    DECLARE @ptrval varbinary(16)
    
    
    SELECT @ptrval = TEXTPTR(LOGG)
    FROM GAMES
    WHERE ID = 21
    
    UPDATETEXT GAMES.LOGG @ptrval NULL NULL 'your text'
    And varchar can be 8000 long.

    Comment

    • Metalzed
      New Member
      • Sep 2006
      • 27

      #3
      Thanks for the help. worked perfekt.




      Originally posted by galexyus
      Hey,

      Use this instead:
      Code:
      DECLARE @ptrval varbinary(16)
      
      
      SELECT @ptrval = TEXTPTR(LOGG)
      FROM GAMES
      WHERE ID = 21
      
      UPDATETEXT GAMES.LOGG @ptrval NULL NULL 'your text'
      And varchar can be 8000 long.

      Comment

      • bayatloo
        New Member
        • Nov 2007
        • 1

        #4
        you can use this samlpe

        UPDATE Yourtable SET Bemerkung = convert(varchar (2000),Bemerkun g) + 'Yourtext hire ' WHERE ID= 111111

        Comment

        Working...