SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 PK & FK
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nsithole
Starting Member

USA
9 Posts

Posted - 10/08/2013 :  07:45:14  Show Profile  Reply with Quote
I created these 4 tables and entered data in columns on borrower and Financial source, but when i enter data in Property table first, I get an error saying ;
Data in row 1 was not commited
Error message:String or binary data would be truncated.Statement has been terminated.

When i switch to enter data in Loan Table first, I get this message::
Insert statement conficted with FK constraint in database "OLTP" table Property_source column 'Property_ID

Below are the constraints

BORROWER: Primary key on SSN

FINANCIAL: Primary Key on SSN and FK referencing Borrower table

LOAN: PK on Loan_ID, FK on SSN ref Borrower and Property ID ref Property table and Co borrower SSN ref borrower table.

PROPERTY: PK on Property ID and FK on SSN ref borrower.



Both Loan_ID &S/S are intergers. I am not sure what I am missing here.


Noreen sithole

James K
Flowing Fount of Yak Knowledge

3559 Posts

Posted - 10/08/2013 :  08:05:22  Show Profile  Reply with Quote
Error message:String or binary data would be truncated.Statement has been terminated.
This error message means that you are trying to enter a string into a column that is not wide enough to store that string. For example, if you had a column that is defined as VARCHAR(5) and you tried to enter a six-character (or longer) string - e.g. "ABCDEF" into that column, you will get this error message.

Insert statement conficted with FK constraint in database "OLTP" table Property_source column 'Property_ID
This message is telling you that there is no row in the PROPERTY table that matches the Property_ID value that you are trying to enter into LOAN table. The foreign key constraint that you set up means that for every row that you want to enter into the LOAN table, the Property_ID value you will be inserting has to be in the PROPERTY table.
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

United Kingdom
3608 Posts

Posted - 10/08/2013 :  08:05:45  Show Profile  Reply with Quote
What other columns do you have in the Property table? You seem to trying to insert a string somewhere that is too long for the field.

Can you post DDL for these tables?
Go to Top of Page

nsithole
Starting Member

USA
9 Posts

Posted - 10/09/2013 :  09:23:32  Show Profile  Reply with Quote
Here are the tables

CREATE TABLE [Loan_Source](
[Loan_ID] [int] NOT NULL,
[SSN] [int] NOT NULL,
[Property_ID] [int] NOT NULL,
[Purpose_of_Loan] [varchar](50) NULL,
[LoanAmount] [int] NULL,
[Purchase_Price] [int] NULL,
[CreditCardAuthorization] [varchar](50) NULL,
[Number_of_Units] [int] NULL,
[Refferal] [varchar](50) NULL,
[Co_Borrower_SSN] [int] NOT NULL)



CREATE TABLE [Property_source](
[Property_ID] [int] NOT NULL,
[SSN] [int] NOT NULL,
[Property Usage] [varchar](50) NULL,
[Property City] [varchar](50) NULL,
[Property State] [varchar](50) NULL,
[Property Zip] [varchar](50) NULL,
[RealEstateAgentName] [varchar](50) NULL,
[RealEstateAgentPhone] [varchar](50) NULL,
[RealEstateAgentEmail] [varchar](50) NULL)


Noreen sithole
Go to Top of Page

nsithole
Starting Member

USA
9 Posts

Posted - 10/09/2013 :  09:54:03  Show Profile  Reply with Quote
Thanks for the reply. I have everything corrected

Noreen sithole
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000