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

x
  • 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]
           ([Employee_Last_Name]
           ,[Employee_First_Name]
           ,[Employee_Middle_Name]
           ,[Title]
           ,[Clinical_Narrative]
           ,[Best_Doctor]
			,Web_address
           ,[appt_emails])
Select lastname, First_Name, MiddleName,credentials,bio,best_doctor, links, appt_emails from #tempNonExistDoctors

DROP TABLE #tempNonExistDoctors;

Open in new window

0
lapucca
Asked:
lapucca
1 Solution
 
_agx_Commented:
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.



0
 
lapuccaAuthor Commented:
Understand, thank you
0

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