Error while Insertin the value for type of Bit

Posted by Self-Innovator under Sql Server on 3/30/2012 | Points: 10 | Views : 1411 | Status : [Member] | Replies : 4
hi friends..
this is my table
CREATE TABLE tblUserMst
(
UserID CHAR(4) CONSTRAINT pk_tblUserMst_UId PRIMARY KEY(UserID),
Password VARCHAR(40) NOT NULL,
Name VARCHAR(70) NOT NULL,
DesigCode CHAR(3) NOT NULL,
EmailId VARCHAR(50) NOT NULL,
TelNo VARCHAR(25),
HandPhone VARCHAR(25),
Active Bit NOT NULL
)


When i'm inserting the values the Column Active is not getting inserted what might be the issue...
 INSERT INTo tblUserMst Values('K001','XYZ','Ali Murtaza','FPP76','ali@ipl.com','9738613250','9765623151',1) 


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


Join Hands Change lives
Thanks & Regards
Straight Edge Society



Responses

Posted by: Rajni.Shekhar on: 3/30/2012 [Member] Bronze | Points: 25

Up
0
Down
yes,

there is problem in length of datatype

DesigCode char(3) and you are inserting FPP76 having more than 3 character, change the length.

Thanks,
Rajni Shekhar

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 3/30/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,
you got this error because your "DesigCode" has type char(3) and your input is having length more than 3 (i.e. "FPP76")

So, either increase data type from Char(3) to Char(5) or change the value.


Mark this as answer, if it helps you....................

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shawnmoran on: 3/30/2012 [Member] Starter | Points: 25

Up
0
Down
I had the same issue and still I can't resolve it..

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/30/2012 [Member] Bronze | Points: 25

Up
0
Down
Error
Msg 8152, Level 16, State 14, Line 1
String or binary data would be truncated.
The statement has been terminated.

this error says, your string is too large to save because in db, column length is short in respective of your data. so always check data lengh.

Thanks,
Rajni Shekhar

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response