[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 286
  • Last Modified:

how to fix error with this vague msg?

How can I find out which column to fix?  Thank you.

(58 row(s) affected)
Msg 8152, Level 16, State 4, Line 12
String or binary data would be truncated.
The statement has been terminated.

if exists (
    select  * from tempdb.dbo.sysobjects o
    where o.xtype in ('U') 
   and o.id = object_id(N'tempdb..#tempNonExistDoctors')
	DROP TABLE #tempNonExistDoctors;

select * into #tempNonExistDoctors from dbo.Doctors
where personID is null;

INSERT INTO [MedDb].[dbo].[person]
Select lastname, First_Name, MiddleName,credentials,bio,best_doctor, links, appt_emails from #tempNonExistDoctors

DROP TABLE #tempNonExistDoctors;

Open in new window

1 Solution
That means one or more of the values you're inserting are too long for the target column.  For example if [person].LastName was a varchar(50) and #tempNonExistDoctors.Lastname was a varchar(100)

The only way to figure out which are the problem columns is to compare the table definitions of [MedDb].[dbo].[person]  and #tempNonExistDoctors (and or the source information) to find out which columns are causing the problem.

lapuccaAuthor Commented:
Understand, thank you

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now