Jul 13
create table #mytb1 (col1 nvarchar(50) not null);insert into #mytb1Select '500910000000000000'union all Select '500903000000000000'union all Select '500909000000000000'union all Select '500903000000000000'union all Select '500805000000000000'union all Select '500911000000000000'union all Select '500905000000000000'union all Select '500911000000000000'union all Select '500905000000000000'union all Select '500911000000000000';-- (10 row(s) affected)Alter table #mytb1 add colnew bigint null ;goupdate #mytb1set colnew = cast( col1 as bigint )where colnew is null ;-- (10 row(s) affected)drop table #mytb1;
select count(*) as newcol_NULL_countfrom yourtable where newcol is null ;
update yourtableset newcol = oldcolwhere newcol is null