无法将此字符串插入到列中。只插入了部分字符串

Unable to insert this string into a column. Only part of the string Is inserted

我正在使用 SQL Server 2008。我试图将一个字符串插入 table,但只插入了字符串的一部分。我检查过是否有SQL注入风险。如何解决或避免这个问题?

insert into tble (col1, col2, col3) 
values (23, 34, "out of 8 works, 5 works are completed");

只插入了Out of 8 Works,跳过了, 5 works are completed

试试这个..

insert into table(col1,col2,col3) values (23,34,'out of 8 works, 5 works are completed');

双引号仅在 QUOTED_IDENTIFIERS 关闭时才有效,如果您担心 SQL 注入,则不要在 INSERT 上传递字符串 - 从应用程序对其进行参数化。字符串可能被截断,因为 col3 的定义不够长 - 还要检查一下。

更改 table 中 col3 的大小(根据您的字符串大小)。 您可以使用以下查询更改它:

改变table表

改变列 col3 nvarchar(100) [null |不为空]