Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Error converting data type nvarchar to numeric. error hidden in stored procedure

$
0
0

I'm running a program that throws this error when it executes a stored procedure.  The stored procedure runs without error when I run it from SSMS.  If I take the queries out of the stored procedure I can produce the error.

I have isolated the error to this particular query in the stored procedure.

Unfortunately I have tried to insert the query as code, but that doesn't appear to work.  So here it is.

declare @ActivityMonth [int]

declare @ActivityYear [int]

declare @SurveyIDint

declare @BranchIDvarchar(50)

set @ActivityMonth= 5

set @ActivityYear= 2013

set @SurveyID= 1869201

set @BranchID='19'

select QuestionID,avg(cast([Value]asdecimal))as responseAVG

from

Response r WITH(NOLOCK)

join

Respondent rt WITH(NOLOCK)on r.SurveyID= rt.SurveyIDand r.Tieback= rt.Tieback

join

Contact c WITH(NOLOCK)on r.SurveyID= c.SurveyIDand r.Tieback= c.Tieback

join

Question q WITH(NOLOCK)on r.SurveyID= q.SurveyIDand r.QuestionID= q.ID

join

Respondent rd WITH(NOLOCK)on r.SurveyID= rd.SurveyIDand r.Tieback= rd.Tieback

where

r.surveyid= @SurveyIDand q.Stylein('SelectOne','SelectAll')

anddatepart(month, [Transaction Date])= @ActivityMonth

anddatepart(year, [Transaction Date])= @ActivityYear

and c.[Tag Field 1] = @BranchID

andisnumeric(value)= 1

and rd.SubmitFinal= 1

group

by QuestionID



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>