sql - 字符串或二进制数据在 asp.net 中将被截断

标签 sql sql-server insert

当我尝试执行时,出现字符串或二进制数据将被截断错误

Insert into Student_info (StudentId,FirstName,LastName,DOB,StudentAddress,StudentEmail,StudentMobile) 
                         (Select StudentId,FirstName,LastName,DOB,Address,EmailId,Mobile from Student_temp where StudentId='" & studentid & "')

Student_Temp的表结构

here

Student_Info的表结构

here

需要帮助!!

最佳答案

当您尝试将字符串或二进制数据插入到宽度不足以容纳的列中时,SQL Server 会报告此错误,例如

create table MyTable
(
    Column1 VARCHAR(10)
)

insert into MyTable (Column1) VALUES ('1234567890A')

Msg 8152, Level 16, State 14, Line 1
String or binary data would be truncated

据猜测,这是因为您的 Student_info.StudentMobilevarchar(10)Student_temp.Mobile 是 varchar(50)

关于sql - 字符串或二进制数据在 asp.net 中将被截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11573294/

相关文章:

sql - 为什么加入需要花费大量时间来执行?

sql - PostgreSQL:更新主键,避免冲突

sql-server - 在 select 语句中指定第一行,然后按字母顺序对其余行进行排序

Apache Ant : Is it possible to insert/replace with text from a raw text file?

php - 将最后添加的条目从一个表插入到另一个表中

php - 在 MySQL 的 X 或 Y 列中返回不同的值

mysql - 从 SQL 中的左连接和内连接中减去计数

sql-server - 捕获等待统计数据

sql-server - SQL 中的正则表达式

c# - 改进 INSERT INTO - FROM SELECT,SQL 查询