從資料類型 nvarchar 轉換為 numeric 時出錯,nvarcharnumeric

來源:互聯網
上載者:User

從資料類型 nvarchar 轉換為 numeric 時出錯,nvarcharnumeric

在寫一個SQL的時候,遇到要將 (字典)表A nvarchar 列 與 表B numeric 列 ,比較大小;

nvarchar 列裡面存的字典資料,需要聯表時通過條件式篩選;

結果我寫好聯表得到表C,並成功載入列表成功;

 

但是在我繼續往 表C後面追加條件時報錯了

 

select * from (select CONVERT(numeric,t2.ItemText) as BZA,t1.* from t1 join dbo.CodeValue t2 on t1.N=t2.ItemValue 
join Codes t3 on t2.CodeID=t3.CodeID and t3.CodeName='字典資料名' ) aawhere  t1.SZ<BZA


最終加了這句,在第一個聯表後面

and ISNUMERIC(t2.ItemText)>0


 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.