我的一个专栏被定义为ntext数据类型,它不再被许多流所支持。我正在尽我最大的努力将该列转换为数字或int,每一次尝试都会到达任何地方。
reg_no #my ntext field | name | country | etc |我试着使用我们都使用的命令来修改col,但是失败了。
alter table tabl1
alter column [reg_no] numeric(38,0)错误:
错误将数据类型nvarchar转换为数字
任何关于修正这个问题的建议,或者是否有人在过去遇到过这个问题,如果是的话,你是如何克服的?
发布于 2021-04-05 18:17:01
您应该能够分两步完成这一任务:
alter table tabl1 alter column [reg_no] nvarchar(max);
alter table tabl1 alter column [reg_no] numeric(38,0);不支持ntext,不支持向numeric的转换,但支持向nvarchar()的转换。
这假设这些值与numeric兼容。否则,您将得到一个类型转换错误。如果发生这种情况,您可以通过以下方法获得违规的值:
select *
from t
where try_convert(numeric(38, 0), try_convert(nvarchar(max), x)) is null发布于 2021-04-05 18:18:56
试试看
从reg_no中选择转换(int,convcert(varchar(40),tabl1 )作为新字段名
https://stackoverflow.com/questions/66957691
复制相似问题