SQL Server - Adding a string to a text column (concat equivalent)

后端 未结 6 1660
一整个雨季
一整个雨季 2021-02-03 20:21

How do you add a string to a column in SQL Server?

UPDATE [myTable] SET [myText]=\' \'+[myText]

That doesn\'t work:

The

6条回答
  •  花落未央
    2021-02-03 20:45

    Stop using the TEXT data type in SQL Server!

    It's been deprecated since the 2005 version. Use VARCHAR(MAX) instead, if you need more than 8000 characters.

    The TEXT data type doesn't support the normal string functions, while VARCHAR(MAX) does - your statement would work just fine, if you'd be using just VARCHAR types.

提交回复
热议问题