Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
474 views
in Technique[技术] by (71.8m points)

sql - Invalid length parameter passed to the LEFT or SUBSTRING function on update statement

While I am not getting any error on running a SQL query using my substring statement, I am getting an error while trying to do the same using update statement.

I am not getting any error while running this:

select distinct o.ID as ClientID,d.ClientName,e.[name] as ClientName
from  Core.dbo.DE_Organization o
inner join [ld].[Me_Claims] d  on SUBSTRING(o.Data_Store,44,ABS(CHARINDEX(';Us',o.Data_Store,34)-44)) = d.ClientName
left join [Consolidated_QA].[dbo].[employer] e
on o.ID=e.leg_emr_id
where o.Data_Store LIKE 'Data Source=SQL%' and d.SourceSystem='M'
order by d.ClientName

I am getting error "Invalid length parameter passed to the LEFT or SUBSTRING function" while running this:

update [Dev].[ld].[Me_Claims]
SET ClientID=o.ID,
ClientName=e.[Name]
FROM Core.dbo.DE_Organization o
    inner join [ld].[Me_Claims] d  on SUBSTRING(o.Data_Store,44,ABS(CHARINDEX(';Us',o.Data_Store,34)-44)) = d.ClientName
    left join [Consolidated_QA].[dbo].[employer] e
    on o.ID=e.leg_emr_id
    where o.Data_Store LIKE 'Data Source=SQL%' and d.SourceSystem='M'

Any idea what is causing this?

question from:https://stackoverflow.com/questions/65621392/invalid-length-parameter-passed-to-the-left-or-substring-function-on-update-stat

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...