Is it possible to use SUM function in a SQL query on a field that has been set as nvarchar but only contains numbers?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is possible by casting:
However, this will throw an exception is 1 or more records cannot be
CASTto anint.If your column is only ever going to have numerical values, I would recommend changing the data type to int to save future problems.
If you are not able to change the data type, then the following
WHEREclause would prevent exceptions from being thrown: