select a.USR_NAME,a.FAX,a.MOBILE,a.EMAIL,b.MC_GROUP_ID,b.CUST_ALIAS,b.CUST_id  from SB_user a,MC_GROUP_CUST_RELATION b ,mc_group c where b.mc_group_id=c.mc_group_id and c.group_type='00 ' and b.cust_id= a.usr_Id and c.creator='sa'
错误:在将 nvarchar 值 'sa' 转换成数据类型 int 时失败。 
如何解决 ?我的另外一条语句select a.contact as USR_NAME,a.FAX,a.mobile_no as MOBILE,a.EMAIL,b.MC_GROUP_ID,b.CUST_ALIAS,b.CUST_id  from sb_cust_contact a,MC_GROUP_CUST_RELATION b, mc_group c where b.mc_group_id=c.mc_group_id and c.group_type='11' and b.cust_id= a.contact_id and c.creator='sa'
就可以运行  这是什么原因?

解决方案 »

  1.   

    select a.USR_NAME,a.FAX,a.MOBILE,a.EMAIL,b.MC_GROUP_ID,b.CUST_ALIAS,b.CUST_id 
    from SB_user a,MC_GROUP_CUST_RELATION b ,mc_group c 
    where b.mc_group_id=c.mc_group_id and c.group_type='00 ' 
    and b.cust_id= a.usr_Id and ltrim(c.creator)='sa'--这样试一试
      

  2.   

    select a.USR_NAME,a.FAX,a.MOBILE,a.EMAIL,b.MC_GROUP_ID,b.CUST_ALIAS,b.CUST_id  
    from SB_user a,MC_GROUP_CUST_RELATION b ,mc_group c  
    where b.mc_group_id=c.mc_group_id and c.group_type='00'  
    and b.cust_id= a.usr_Id and ltrim(c.creator)='sa'
      

  3.   

    and c.creator='sa'這一列查看一下Creator是否為int類型,如果為int沒應該加字符條件
      

  4.   

    Creator  是 nvarchar 类型的    我加了ltrim()还是提示错误:在将 nvarchar 值 'sa' 转换成数据类型 int 时失败。
      

  5.   


    select 
    a.USR_NAME,a.FAX,a.MOBILE,a.EMAIL,
    b.MC_GROUP_ID,b.CUST_ALIAS,b.CUST_id 
    from 
    SB_user a,MC_GROUP_CUST_RELATION b,mc_group c 
    where 
    b.mc_group_id=c.mc_group_id and c.group_type='00' 
        and b.cust_id= a.usr_Id and ltrim(c.creator)='sa'我没有得到你这个错误呀?
      

  6.   

    还是一样提示在将 nvarchar 值 'sa' 转换成数据类型 int 时失败。Creator是nvarchar类型的
      

  7.   

    知道原因了··汗··usr_Id 是int 类型的··   cust_id是nvarchar类型的   应该怎么强制转换?
      

  8.   

    select a.USR_NAME,a.FAX,a.MOBILE,a.EMAIL,b.MC_GROUP_ID,b.CUST_ALIAS,b.CUST_id from SB_user a,MC_GROUP_CUST_RELATION b ,mc_group c where b.mc_group_id=c.mc_group_id and c.group_type='00 ' and cast(b.cust_id as int)= a.usr_Id and c.creator='sa'
    试试看呢