简体   繁体   English

如何将nvarchar转换为int然后在sql server中添加

[英]how to cast nvarchar to int then add in sql server

i do not understand that what wrong in this query 我不明白这个查询有什么问题

select cast(B1 as int)+
       (cast(H1 as int)+
       (cast(C1 as int)+
       (cast(I1 as int)) as [man] 
From Kanpur

B1, H1, C1, I1 is declared as nvarchar in database 在数据库中将B1, H1, C1, I1声明为nvarchar

error: Incorrect syntax near the keyword 'as'.

You are missing the closing parantheses. 您缺少结尾括号。

select (cast(B1 as int)+cast(H1 as int)+cast(C1 as int)+cast(I1 as int)) as [man]
From Kanpur

Missing parenthesis...write as: 缺少括号...写为:

select cast(B1 as int)+
       (cast(H1 as int))+
       (cast(C1 as int))+
       (cast(I1 as int)) as [man] 
From Kanpur

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM