Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 String or binary data would be truncated.

Author  Topic 

junior6202
Starting Member

45 Posts

Posted - 2015-01-29 : 09:41:44
I'm new to Sql but I understand the basics and maybe a bit intermediate. I wrote this query to pull some information involving 3 tables dbo.NewFamNbrs$, dbo.CGIItemMaster and dbo.CGIFamilyMaster. In addition I want to perform an update statement to update column dbo.CGIItemMaster.FamilyIDX with the information of dbo.CGIFamilyMaster.IDX. I also know that truncation is indicating that I'm trying to insert data into a field not large enough. So I performed a len() function on the both columns and order by desc and they both came up with 4 as being the max. I'm out of ideas any help will be appreciated.

Query:

SELECT a.PART, a.Family, b.FamilyIDX, c.FamilyID, c.IDX
FROM dbo.NewFamNbrs$ a LEFT OUTER JOIN dbo.CGIFamilyMaster c ON a.Family = c.FamilyID LEFT OUTER JOIN dbo.CGIItemMaster b ON a.PART = b.PART



Results of query:

PART Family FamilyIDX FamilyID IDX
000127233 TF01 1468 TF01 506
000129880 TF01 1468 TF01 506
003110 MET06 1468 MET06 1915


UPDATE STATEMENT:

begin tran
update dbo.CGIItemMaster
set FamilyIDX=c.IDX
FROM dbo.NewFamNbrs$ a LEFT OUTER JOIN
CGIFamilyMaster c ON a.Family = c.FamilyID LEFT OUTER JOIN
dbo.CGIItemMaster b ON a.PART = b.PART

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2015-01-29 : 11:01:33
Some table definitions would help...



Those who will not reason, are bigots, those who cannot, are fools, and those who dare not, are slaves. -Lord Byron, poet (1788-1824)
Go to Top of Page

junior6202
Starting Member

45 Posts

Posted - 2015-01-29 : 11:12:43
Both of the IDX and the FamilyIDX size is 4



dbo.NewFamNbrs$
PART varchar(50)
Family varchar(25)

dbo.CGIFamilyMaster
FamilyID varchar(25)
IDX int

dbo.CGIItemMaster
FamilyIDX int
PART varchar(50)
Go to Top of Page
   

- Advertisement -