2017-03-03 104 views
0

当我尝试执行整个过程时发生此错误。以下是程序中的一段代码。将nvarchar值'B'转换为数据类型时转换失败int

SELECT 
    DISTINCT SUBSTRING (a.GL06001,19,10) as ProjectNo, 
    --PR01040 UD_10, 
    SUBSTRING (a.GL06001,1,8)  as AccountNo, 
    a.GL06002    as TransNo, 
    a.GL06004    as TransAmount, 
    a.GL06003    as TransDate, 
    a.GL06005    as TransDesc, 
    'GL'     as SourceType, 
    ' '     as ResourceCode, 
    ' '      as TransLine, 
    0     as CostPR, 
    '000000'    as PRTransNo, 
    a.GL06027    as SubprojNo, 
    a.GL06028    as ActiLineNo, 
    a.GL06012    as TransType, 
    a.GL06016    as Counter 
    from ScalaMX.dbo.GL06PA17 a where a.GL06003 between '2017-02-21 00:00:00.000' and '2017-03-01 00:00:00.000' 

实际上有18000多行和15列。有关如何跟踪哪个列具有B值的任何提示?

我在Excel中下载了结果并按Ctrl + f'B'但仍然没有线索,我找不到它。

回答

0

转换成存储的过程,见下文样品

declare 
    n integer; 
    m integer; 
begin 
    for i in (select primarykeycolumn, a,b from table) 
    loop 
    begin 
     n := i.a; 
     m := i.b; 
    exception 
     when others then 
      dbms_output.put_line(i.primarykeycolumn); 
    end 
    end loop; 
    end; 

当转换发生错误,将捕捉异常因此找到的主键。