For example, maybe TransactionSetCode is a text column and you should write Aux.TransactionSetCode = '278'
and Aux.TransactionSetCode = '270'
instead of Aux.TransactionSetCode = 278
and Aux.TransactionSetCode = 270
. Or maybe there are other columns that contain “NONE” instead of numbers.
Msg 245, Level 16, State 1, Line 2 Conversion failed when converting the varchar value 'NONE' to data type int.
My query is below, and I am not understanding the correlation of the error. FYI I have been running this query for several months on a daily basis and am only now getting this error.
Msg 245, Level 16, State 1, Line 2
Conversion failed when converting the varchar value 'NONE' to data type int.
Begin
With Temp_CTE_278 as
(
Select aux.EpisodeID
from [Websphere].[dbo].[tblWebTXLog] as Wlog with (nolock)
Inner Join [Websphere].[dbo].[tblWebTXLogAux] as Aux with (nolock) on Wlog.LogId=Aux.LogID
INNER JOIN [CCNIDCTIER1SQL].[Pre-AuthThin].[dbo].[tblAuthorization] as Auth with (nolock) ON aux.EpisodeID = Auth.EpisodeID
Where Auth.AuthStatus='A' and Aux.TransactionSetCode =278 and Aux.Episodeid<>''
and Auth.InsCarrier like '1199%' and Aux.EpisodeDate>='2023-5-15'
)
Select Distinct Aux.EpisodeID,Aux.TransactionSetCode,Aux.EpisodeDate,Auth.AuthStatus
from [Websphere].[dbo].[tblWebTXLog] as Wlog with (nolock)
Inner Join [Websphere].[dbo].[tblWebTXLogAux] as Aux with (nolock) on Wlog.LogId=Aux.LogID
INNER JOIN [CCNIDCTIER1SQL].[Pre-AuthThin].[dbo].[tblAuthorization] as Auth with (nolock) ON aux.EpisodeID = Auth.EpisodeID
Where Auth.AuthStatus='A' and Aux.TransactionSetCode =270 and Aux.Episodeid<>''
and Auth.InsCarrier like '1199%' and Aux.EpisodeDate>='2023-5-15'
and Aux.EpisodeID Not In(select EpisodeID from Temp_CTE_278)
Order by Aux.EpisodeID,Aux.EpisodeDate Asc
End
SQL Server | Other
-
Viorel 122.6K Reputation points
2023-05-26T19:56:53.62+00:00