SQL QUery Error string or binary data would be truncated

Here is my query -
INSERT	OUTLOOKREPORT.DBO.loanselect
(	Borrower
,	[address]
,	[status]
,	xrefid
)
SELECT	a.BorrowerFirstName + ' ' + a.BorrowerLastname
,	a.Address1
,	a.CurrentMileStoneName
,	a.xrefid
FROM	emdb.emdbuser.loansummary	a
LEFT
JOIN	OUTLOOKREPORT.DBO.loanselect	b	ON	a.XREFID = b.XREFID
WHERE	b.XREFID IS NULL

--Inserts xrefid from Encompass into Interface
INSERT	OUTLOOKREPORT.DBO.xrefidtable
(	xrefid
)
SELECT		a.xrefid
FROM	emdb.emdbuser.loansummary	a
LEFT
JOIN	OUTLOOKREPORT.DBO.xrefidtable	b	ON	a.XREFID = b.XREFID
WHERE	b.XREFID IS NULL

Open in new window


Here is what it is outputting and I cant find my error.

Msg 8152, Level 16, State 4, Line 1
String or binary data would be truncated.
The statement has been terminated.

(0 row(s) affected)

Open in new window

desiredforsomeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

brasso_42Commented:
Have a look at the field lengths and the length of the data you are trying to insert
Jim HornMicrosoft SQL Server Data DudeCommented:
Eyeballeth thy character lengths in your SELECT clause, as one or more of these is greater than the colum in the INSERT clause that you're trying to INSERT into.  

For example, this returns the same error, which tries to insert a six-character string into a two-character column:
SET ANSI_WARNINGS ON

CREATE TABLE #tmp (us_state char(2)) 

INSERT INTO #tmp (us_state)
SELECT 'banana'

Open in new window


Start with the firstname + ' ' + lastname, as if both names are 50, then this requires a column of 50 + 1 + 50 = 101 character length, not 100.
Vitor MontalvãoMSSQL Senior EngineerCommented:
You may trying to insert all United States inside UK.
Check the lengths for Borrower, address and status from loanselect table and compare it respectively with the length of (BorrowerFirstName + ' ' + BorrowerLastname), Address1 and CurrentMileStoneName from loansummary table.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
desiredforsomeAuthor Commented:
I haveth seen thy problem thansk to you all. Indeed you cannot fit US in the UK. increased NVARCHAR to 100 from 50 as the other table was 100.

Thanks!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.