Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String or binary data would be truncated

I am trying to execute the following SQL query using MS SQL Server Management Studio express.

 Insert INTO SU_PRO_RE ( d_id, fis_year, last_dp, budget_amt)  VALUES ( 'A','2011', 0, 205000.00);

Everything looks correct to me but every time i try to execute it it has the following:

String or binary data would be truncated.
The statement has been terminated.

(0 row(s) affected)

The tables as set as follows:

d_id        = char(1) *PK*
fis_year    = char(2) *PK*
last_dp     = smallint
budget_amt  = money

I'm not sure what i am doing incorrect but i'm sure i am just over looking something very obvious so any help would be great! :)

Thanks, David

like image 314
StealthRT Avatar asked Dec 22 '22 17:12

StealthRT


1 Answers

fis_year is defined as char(2) but you're trying to insert a 4 character value of '2011'.

like image 177
Joe Stefanelli Avatar answered Jan 02 '23 05:01

Joe Stefanelli