I’m under the impression that SQL Server will allow me to perform addition such as
SELECT val01, val02, val03 = (val01 + val02)
FROM Table_1
so that val03 is the addition of the two previous columns. However, in this instance I am literally seeing value 1 next to value 2. Can you show me where I’m going wrong?
The
+operator has two uses in SQL Server:int,bigint,decimal, etc) it is an ADDITION operator.varchar,nvarchar,char, etc) it is a CONCATENATION operator.If you have numerical data in a string datatype field, you will see the second value appended to the first.
The solution is to either:
val03 = (CAST(val01 as int) + CAST(val02 as INT))