久久久久久久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| 午夜精品一区二区三区三上悠亚 | 国产乱码精品一品二品 | 网站黄色在线 | 欧美激情精品久久久久久变态 | 欧美亚洲国产日韩 | 中文字幕免费在线 | 亚洲伊人a | 久久久中文 | 免费国产一区 | 一区二区三区国产 | 97国产精品视频 | 国产欧美一区二区三区另类精品 | 亚洲精品第一国产综合野 | 99久久99 | 九九国产在线观看 | 一本大道久久a久久精二百 欧洲一区二区三区 | 精品一区二区电影 | 国产美女一区二区 | 国产精品成人一区 | 无码国模国产在线观看 | 欧美不卡一区二区三区 | 美女操网站| 在线观看中文字幕 | 二区三区视频 | 亚洲综合日韩精品欧美综合区 | 久久久久久久国产精品视频 | 一级a爱片久久毛片 | 久久精品国产一区二区电影 | 综合九九| 国产综合精品一区二区三区 | 精品伊人久久 | 成人一区二区在线 | 特级黄一级播放 | 国产精品久久久久久久毛片 | 国产精品久久久久久影院8一贰佰 |