Msg 8152, Level 16, State 14, Line 1. String or binary data would be truncated.

Reason: The data can’t be inserted because the column is not defined with enough space.

INTERVIEW PREPARATION IN 30 MINs – Read Following wires for a quick interview preparation.

  1. SQL Server DBA “Interview Questions And Answers”
  2. SQL Azure Interview Questions and Answers Part – 1
  3. SQL Azure Interview Questions and Answers Part – 2
  4. Powershell Interview Questions and Answers

Below is the example. Can you find out which column is giving problem?

CREATE TABLE RailwayTicket(RlTktNo INT, PassengerName VARCHAR(20), Profession VARCHAR(10), Date datetime)
INSERT INTO RailwayTicket
SELECT 12020,’Passenger1′,’Teacher’,getdate()
UNION
SELECT 12021,’Passenger2′,’Teacher’,getdate()
UNION
SELECT 12022,’Passenger3′,’Teacher’,getdate()
UNION
SELECT 12023,’Passenger4′,’Businessman’,getdate()

Yes.. This is Profession.

Run script to correct the datatype/length of the respective column and you are good to go. “ALTER TABLE ALTER COLUMN”

 
ALTER TABLE RailwayTicket
ALTER COLUMN Profession VARCHAR(20)
Regards,
Online MSSQL Classes @ http://tuitionaffordable.webstarts.com
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s