久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

SQL Server - 將字符串添加到文本列(concat 等效項)

SQL Server - Adding a string to a text column (concat equivalent)(SQL Server - 將字符串添加到文本列(concat 等效項))
本文介紹了SQL Server - 將字符串添加到文本列(concat 等效項)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如何向 SQL Server 中的列添加字符串?

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

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

這不起作用:

數據類型 varchar 和 text 在加法運算符中不兼容.

The data types varchar and text are incompatible in the add operator.

你會在 MySQL 上使用 concat,但你如何在 SQL Server 上使用它?

You would use concat on MySQL, but how do you do it on SQL Server?

推薦答案

就像之前所說的,最好將列的數據類型設置為 nvarchar(max),但如果這不可能,您可以使用 cast 或 convert 執行以下操作:

like said before best would be to set datatype of the column to nvarchar(max), but if that's not possible you can do the following using cast or convert:

-- create a test table 
create table test (
    a text
) 
-- insert test value
insert into test (a) values ('this is a text')
-- the following does not work !!!
update test set a = a + ' and a new text added'
-- but this way it works: 
update test set a = cast ( a as nvarchar(max))  + cast (' and a new text added' as nvarchar(max) )
-- test result
select * from test
-- column a contains:
this is a text and a new text added

希望有幫助

這篇關于SQL Server - 將字符串添加到文本列(concat 等效項)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

SQL trigger on Truncate(截斷時的 SQL 觸發器)
sql search query with multiple optional search parameters(具有多個可選搜索參數的 sql 搜索查詢)
SQL Efficiency: WHERE IN Subquery vs. JOIN then GROUP(SQL 效率:WHERE IN 子查詢 vs. JOIN 然后 GROUP)
Retrieving XML element name using t-SQL(使用 t-SQL 檢索 XML 元素名稱)
Insert double quotes into SQL output(在 SQL 輸出中插入雙引號)
Delete rows from CTE in SQL SERVER(從 SQL SERVER 中的 CTE 中刪除行)
主站蜘蛛池模板: 国产欧美一区二区 | 欧美在线亚洲 | 精品九九九 | 日韩一级片 | 亚洲美女网站 | 国内精品久久久久 | 成人免费精品 | 91成人国产 | 婷婷激情五月 | 97精品国产97久久久久久免费 | 国产福利在线播放 | 9999精品视频| 中文字幕免费 | 玖玖视频 | 欧美一区二区三区的 | 亚洲一区欧美 | 久久新视频 | 欧美精品久久99 | 激情综合五月婷婷 | 欧美日韩综合 | www中文字幕 | 精品国产91| 三级免费网站 | 97视频在线 | 天天视频国产 | 国产三级视频在线播放 | 99中文字幕 | 九九久久久| 亚洲天堂网站 | 国产日本在线观看 | 日韩高清精品免费观看 | 久久国产一区二区 | cao视频 | 日韩av免费在线观看 | 中文字幕一二区 | 日本免费在线视频 | 午夜在线视频观看日韩17c | 国产精品久久久久久无人区 | 亚洲天堂偷拍 | 天天操天天干天天操 | 日韩大片在线观看 |