sql - 如何在 SQL Server 查询中连接文本?

标签 sql sql-server

以下 SQL:

SELECT notes + 'SomeText'
FROM NotesTable a 

给出错误:

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

最佳答案

唯一的方法是将文本字段转换为 nvarchar 字段。

Select Cast(notes as nvarchar(4000)) + 'SomeText'
From NotesTable a

否则,我建议在您的应用程序中进行串联。

关于sql - 如何在 SQL Server 查询中连接文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54334/

相关文章:

SQL Server : select the largest order total from multiple customers with multiple orders, 并且每个订单上有多个项目

c# - EF6 : Modifying an entity property with a foreign key relation - Do I need to change the Id or the related object or both?

sql-server - 字符串或二进制数据将被截断。该语句已终止。 System.Data.SqlClient.SqlException (0x80131904)

javascript - 如何使用 node.js 和连接池一次建立到 SQLServer 数据库的多个连接?

sql-server - SQL Server 数据库图显示关系

SQL 服务器 : average sales with Date Range Criteria

sql - 如何知道 SSIS 在哪一行无法解析平面文件中的数据

sql - 在数据透视表的日期时间列上聚合

sql - 使用 Tablediff 比较所有表

mysql - 即使在 MYSQL 表中互换时,如何使两行唯一?