[2008] Operand data type text is not a valid sum operator (SQL SRV 2005)
Can anyone tell me why this error is happening?
My connection string is correct, my table is called Table2, my Column is called Name, and my data type is 'Text'
Code:
vb.net Code:
Dim connection As New SqlConnection("fake_connection_string_for_this_post")
Dim command As New SqlCommand("SELECT SUM(Name) FROM Table2", connection)
connection.Open()
Dim nam As String= CStr(command.ExecuteScalar())
connection.Close()
Dim name As String = CStr(command.ExecuteScalar()), is the line it errors on
The actual error is in the title, but I will repeat it again:
Operand data type text is not a valid sum operator
Can anyone help?
Thanks
Re: [2008] Operand data type text is not a valid sum operator (SQL SRV 2005)
Fixed it, the SQL syntax was wrong, it had SUM(Name) instead of just (Name) in the code
Cheers