Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I am trying To sum of nvarchar column in sql query in vb.net. But its showing incorrect syntax near ). Here is my query -
SqlCmd = New SqlCommand("SELECT SUM(CAST(BasicSal AS double)) AS BasicSalary FROM vwGetEmpCntrctWisePaymnt",ConnString)
My BasicSal is nvarchar column in SQL Server2000.
Any help will be highly appreciated.
Posted
Updated 22-Mar-15 5:13am
v3

"double" is not a valid SQL datatype: did you mean "FLOAT"?
SQL
SqlCmd = New SqlCommand("SELECT SUM(CAST(BasicSal AS FLOAT)) AS BasicSalary FROM vwGetEmpCntrctWisePaymnt",ConnString)


DOUBLE is an alias, and they aren't allowed in CAST functions.
 
Share this answer
 
Try this:
SELECT SUM(CAST(BasicSal AS decimal)) AS BasicSalary FROM vwGetEmpCntrctWisePaymnt
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900