Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help fix SQL "String or binary data would be truncated."

Status
Not open for further replies.

BG12424

Programmer
Jun 4, 2002
717
US
I was wondering if someone could help me figure out how to fix my SQL as a result of this error message I'm getting with the following SQL below. Thanks

Error Message:
Server: Msg 8152, Level 16, State 9, Line 24
String or binary data would be truncated.
Warning: Null value is eliminated by an aggregate or other SET operation.
The statement has been terminated.

Code:
			declare @tblBidList table (
				BidId int primary key,
				ProjectName varchar(200), 
				FacilityRate money,
				GroupNum int, 
				BidDate datetime, 
				RecruitNum int, 
				HoldStatus varchar(50), 
				BidStatus varchar(50), 
				ClientFoodLowDollar money, 
				ClientFoodHighDollar money, 
				Notes varchar(500), 
				RespondentFood varchar(100), 
				TypeCode varchar(50), 
				UserID int,
				ClientID int, 
				ClientContactID int, 
				FacilityID int, 
				ActiveFlag bit, 
				MaxStudyDate datetime,
				MinStudyDate datetime
			)
			
[b]Error Line Number is here[/b]
			insert into @tblBidList (
				BidId,
				ProjectName, 
				FacilityRate,
				GroupNum, 
				BidDate, 
				RecruitNum, 
				HoldStatus, 
				BidStatus, 
				ClientFoodLowDollar, 
				ClientFoodHighDollar, 
				Notes, 
				RespondentFood, 
				TypeCode, 
				UserID,
				ClientID, 
				ClientContactID, 
				FacilityID, 
				ActiveFlag, 
				MaxStudyDate,
				MinStudyDate
			) 
			select 	b.BidId, 
				b.ProjectName, 
				b.FacilityRate, 
				b.GroupNum, 
				b.BidDate, 
				b.RecruitNum, 
				b.HoldStatus, 
				b.BidStatus, 
				b.ClientFoodLowDollar, 
				b.ClientFoodHighDollar,
				b.Notes, 
				b.RespondentFood, 
				b.TypeCode, 
				b.UserId, 
				b.ClientId, 
				b.ClientContactId,
				b.FacilityId, 
				b.ActiveFlag,
				max(bsd.StudyDate), 
				min(bsd.StudyDate)
			from 	tblBidStudyDate bsd, 
				tblBids_bak_07112006 b
			where 	upper(b.BidStatus) not in ('CONVERTED TO JOB','CANCELLED','EXPIRED')
			and	b.BidId *= bsd.BidId
			group by 
				b.BidId, 
				b.ProjectName, 
				b.FacilityRate, 
				b.GroupNum, 
				b.BidDate, 
				b.RecruitNum, 
				b.HoldStatus, 
				b.BidStatus, 
				b.ClientFoodLowDollar, 
				b.ClientFoodHighDollar,
				b.Notes, 
				b.RespondentFood, 
				b.TypeCode, 
				b.UserId, 
				b.ClientId, 
				b.ClientContactId,
				b.FacilityId, 
				b.ActiveFlag


regards,
Brian

 
Warning: Null value is eliminated by an aggregate or other SET operation."

That is a normal warning with GROUP BY. It means that one or more rows has a NULL in a column that is being aggregated. Especially with OUTER JOIN of a deficient table.

This may be ignored, or you may add an expression using ISNULL(column, value_if_null) or a WHERE condition to eliminate such rows.



"String or binary data would be truncated."

This means that the datatype of some column in the source table used in the SELECT statement is larger than the corresponding column in the target table used in the INSERT statement. The data does not fit.

This must be corrected by declaring the table with appropriate datatypes; or by using an expression to limit the size of the data being inserted.
 
Thanks, i just resolved the issue and it was the fact that my column size was incompatible with what I was allowing to be updated. All better now, thanks

regards,
Brian

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top