Updating A Table Having A Foreign Key Constraint

Nov 10, 2006

Hi

I am trying to update tables "Table A" & " TableB" with a new value for a particular column1. Now "TableA" contains a foreign key "FK1" defined on it and is referencing another table "Table B" containing the similar column "Column1"

Because of this constraint I was not able to update TableA and TableB. My question is

1) If i wanted to go ahead with this update, what are the possible ways?

2) If only solution is to drop the constraint. Then How do i know the definition for this particular Foreign key, i mean it may refer some columns in Table B. I wanted to know the complete definition of it so that i can rebuild the constraint after the update. Right now i can see only the constraint name when i use sp_help TableA. But how do i know the complete reference made by this foreign key.



Early reply is much appreciated



Thanks!

View 3 Replies


ADVERTISEMENT

Cannot Truncate Table 'Database.dbo.Table' Because It Is Being Referenced By A FOREIGN KEY Constraint..

Aug 23, 2006

Here is my issue I am new to 2005 sql server, and am trying to take my old data which is exported to a txt file and import it to tables in sql. The older database is non relational, and I had made several exports for the way I want to build my tables. I built my packages fine and everything is working until I start building relationships. I remove my foreign key and the table with the primary key will get updated for the package again. I need to update the data daily into sql, and once in it will only be update from the package until the database is moved over.

It will run and update with a primary key until I add a foreign key to another database.

Here is my error when running the package when table 2 has a foreign key.

[Execute SQL Task] Error: Executing the query "TRUNCATE TABLE [consumer].[dbo].[Client] " failed with the following error: "Cannot truncate table 'consumer.dbo.Client' because it is being referenced by a FOREIGN KEY constraint.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

View 3 Replies View Related

The INSERT Statement Conflicted With The FOREIGN KEY Constraint 'Table'

Jan 11, 2008

 Hi,A conflict error occured when I insert data using Formview.The INSERT statement conflicted with the FOREIGN KEY constraint "FK_personal_personal_category". The conflict occurred in database "E:INETPUBWWWROOTWEBSITEAPP_DATADATABASE.MDF", table "dbo.personal_category", column 'cat_id'.The statement has been terminated. ----------------------------------------------------Personal TablepID (primary)pNamecat_id (foreign key from personal_category, which has a relationship with it's primary key cat_id)pID | pName | cat_id1 | Scott | 112 | John | 122 | Mick | 13-----------------------------------------------------Personal_Category Tablecat_id (primary)cat_Descriptioncat_id | cat_description11 | Dean12 | Student13 | Professor-----------------------------------------------------I'm inserting a new data on Personal Table while choosing a category usinga DropdownList which is binded to another DataSource (LinqDataSource2).... <asp:FormView ID="FormView1" runat="server" DataKeyNames="tut_id" DataSourceID="LinqDataSource1"            BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px"            CellPadding="4" DefaultMode="Insert" ForeColor="Black" GridLines="Vertical">            <FooterStyle BackColor="#CCCC99" />            <RowStyle BackColor="#F7F7DE" />            <InsertItemTemplate>            <asp:TextBox ID="pName" runat="server" Text='<%# Bind("pName") %>' />            <br />            <asp:DropDownList ID="DropDownList1" runat="server"                  DataSourceID="LinqDataSource2" DataTextField="cat_desc" DataValueField="cat_id" DataSource='<%# Bind("tut_cat") %>' >            </asp:DropDownList>            </InsertItemTemplate>            <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />            <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />            <EditRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" /> </asp:FormView>        <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="PersonalsDataContext"            TableName="Personal" EnableInsert = "true">                     </asp:LinqDataSource>        <asp:LinqDataSource ID="LinqDataSource2" runat="server" ContextTypeName="PersonalCategoriesDataContext"            TableName="Personal_categories" EnableInsert="false" >        </asp:LinqDataSource>...  Hope you could help.cheers,imperialx 

View 2 Replies View Related

Updating A Table With A Foreign Key

Sep 27, 2006

Hi,

I have a datatable with the following values:

ID

CompanyID

CompanyName.

Here ID is the foreign key. I was wondering if there was a way to update tables with foreign keys. Searching for stuff gave me something like update cascade. Can somebody please elaborate on that?

View 3 Replies View Related

INSERT Statement Conflicted With COLUMN FOREIGN KEY SAME TABLE Constraint

Aug 1, 2006

For some reason, I'm getting this error, even without the DBCC Check:

INSERT statement conflicted with COLUMN FOREIGN KEY SAME TABLE constraint 'Category_Category_FK1'. The conflict occurred in database 'mydb', table 'Category', column 'CategoryID'.
The statement has been terminated.

The very first insert fails...it was working fine before:


DELETE Category;

-- Now, insert the initial 'All' Root Record

INSERT INTO Category
(ParentCategoryID, [Name], [Description], DisplayOrder, DisplayInExplorer, Keywords, Active, CreateDate, CreateUserID, UpdateDate, UpdateUserID )
SELECT 1, CategoryName, '', 1, 1, '', 1, GETDATE(), 1, GETDATE(), 1 FROM CategoriesStaging WHERE CategoryName = 'All'

INSERT INTO Category
(ParentCategoryID, [Name], [Description], DisplayOrder, DisplayInExplorer, Keywords, Active, CreateDate, CreateUserID, UpdateDate, UpdateUserID )
SELECT 2, CategoryName, '', 1, 1, '', 1, GETDATE(), 1, GETDATE(), 1 FROM CategoriesStaging WHERE CategoryName = 'Store'


/* Finally, insert the rest and match on the Parent
Category Name based on the CategoryStaging table
*/

WHILE (@@ROWCOUNT <> 0)
BEGIN
INSERT INTO Category
(ParentCategoryID, [Name], [Description], DisplayOrder, DisplayInExplorer, Keywords, Active, CreateDate, CreateUserID, UpdateDate, UpdateUserID)
SELECT c.CategoryID, s.CategoryName, '', 1, 1, '', 1, GETDATE(), 1, GETDATE(), 1
FROM Category c INNER JOIN CategoriesStaging s ON c.[Name] = s.ParentCategoryName
WHERE NOT EXISTS (SELECT 1 FROM Category c WHERE s.[CategoryName] = c.[Name])
AND s.CategoryName <> 'All'


Here's the schema:

CREATE TABLE [dbo].[Category](
[CategoryID] [int] IDENTITY(1,1) NOT NULL,
[ParentCategoryID] [int] NULL,
[Name] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,

CONSTRAINT [Category_PK] PRIMARY KEY CLUSTERED
(
[CategoryID] ASC
) ON [PRIMARY]
) ON [PRIMARY]

GO
USE [mydatabase]
GO
ALTER TABLE [dbo].[Category] WITH NOCHECK ADD CONSTRAINT [Category_Category_FK1] FOREIGN KEY([ParentCategoryID])
REFERENCES [dbo].[Category] ([CategoryID])

View 8 Replies View Related

Data Access :: Cannot Truncate Table Because It Is Being Referenced By FOREIGN KEY Constraint

Nov 11, 2015

Am working on sql database table shifting to new database tables. Am getting the following error while truncating the tables:-

Cannot truncate table 'orderItem' because it is being referenced by a FOREIGN KEY constraint.How can i remove all the items in the table if i found this error.

View 7 Replies View Related

How To Reset The Identity Counter On A Table Referenced By A FOREIGN KEY Constraint?

Apr 4, 2006

I know that TRUNCATE TABLE can be used to reset the identity counter, but it can't be used on a table referenced by a foreign key. Anybody knows how to do that? Thanks.

View 4 Replies View Related

Updating Values In A Table With Foreign Key Violations

Aug 25, 2004

Hello!
I have a "current" table which users update on a daily basis, it holds forecast data. This table is designed to only hold 7 days of data and is therfore always rolling over by date.
What I want to do is have a procedure that copies this "Current" table to a "History" table every day so the historical information is stored. The copy is simple, but how do I check for and over ride values that are already in the "history" table with the newest values from the "current" table because the "current" values have the possibility of changing a few times while the forecast is updated. I can define a primary key but am not sure how to check for and update the necessary values?

Any help??

Many thanks!

View 1 Replies View Related

Foreign Key Constraint

Aug 11, 1999

student --- enrollment is 1- to - many . ssn is pk in student. ssn and courseid is pk in enrollment. later I added the foreign key constraint FK_SSN in enrollment table reference student table. it is ok.
enrollment --- lessonhistory is 1-to -many, ssn, courseid and lessonid is pk in lessonhistory . I tried to set FK_SSN foreign key constraint in lessonhistory table reference enrollment table, it always show error message " no primary key in referewnce talbe enrollment "
I don't know how to fix it. could you help me out, thanks!!

View 1 Replies View Related

Foreign Key Constraint

Nov 20, 2011

I have a created a database with nearly 20 tables in it, so I cannot post all of my statements. I am having an issue though with two tables' referential integrity when it comes to foreign key constraints. I want to constrain them to cascade updates from the primary key tables, but I keep getting the error msg 1785

Introducing FOREIGN KEY constraint 'FK__PURCHASE___ITEM___64F971E5' on table 'PURCHASE_ORDER_LINE' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.

Here is the table with the primary key:
create table MERCHANDISE (
ITEM_ID varchar (8) NOT NULL PRIMARY KEY,
DESCRIPTION CHAR (60),
STANDARD_PRICE MONEY,

[code]...

I have tried making an update trigger but it does not work.

View 3 Replies View Related

Foreign Key Constraint

Apr 25, 2006

i have a publication that is composed of

many articles. The publication is composed of many

realated tables. I'm doing a snapshot replication



Is there a way to specify the order by which table

must synchonize.



lets say. article 1 synchonizes first, then article 3, then article 2



View 1 Replies View Related

DTS And Foreign Key Constraint Problem

Jan 3, 2002

Hi

I am attempting to write a DTS package that copies the data across from one instance of a db on a test server to a second instance on to the live server. It has to replace all the exisiting date so I can't append. Unfortunately, the package keeps giving me errors all of the type "unable to truncate tbl due to foreign key constraints". Is there a way round this?

Thanks

Steve

View 2 Replies View Related

Disabling FOREIGN KEY Constraint...

Jan 11, 2007

sql 2000, northwind databse

code in sql analyzer:


Code:


ALTER TABLE categories NOCHECK CONSTRAINT ALL
TRUNCATE TABLE categories
ALTER TABLE categories CHECK CONSTRAINT ALL



but still i am getting the error:

Quote: Server: Msg 4712, Level 16, State 1, Line 2
Cannot truncate table 'categories' because it is being referenced by a FOREIGN KEY constraint.

what i need to do is write a query that just cleans all the tables of all data.

View 4 Replies View Related

Introducing FOREIGN KEY Constraint

Feb 10, 2004

"Introducing FOREIGN KEY constraint 'FK__APPLICANTMA__SEX__414EAC47' on table 'APPLICANTMASTER' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints."


ive a foreign key reference on the table APPLICANT MASTER
of the form
FOREIGN KEY (SEXCODE) REFERENCES
APPLICANTSEX(SEXCODE)
ON DELETE NO ACTION
ON UPDATE CASCADE,


can any one help me WHAT THE MESSAGE MEANS ?

View 5 Replies View Related

Foreign Key Constraint Error

Apr 9, 2008

Hi all, I'm new here so I hope this is the right place to post!!

I'm having a really big problem trying to make a table. I'm not new to the coding, but I'm no expert either.... as far as I can see I haven't done anything wrong...

I have many tables, but the first two are JobDetails and Promotions... in JobDetails, there is a primary key Job which needs to link to Promotions as a foreign key.... here is my code and errors, I'd really appreciate some help...


create table JOBDETAIL
(Job varchar2(15) primary key,
Dept varchar2(10) not null,
Salary number(7) not null);


create table PROMOTION
(PCID number(6) primary key,
PDate date,
Constraint fkey_p1 foreign key (Job) references JOBDETAIL(Job));

ERROR at line 4:
ORA-00904: "Job": invalid identifier



... any help would be appreciated, this is quite important... thank you!!!

View 1 Replies View Related

Need Help Adding Foreign Key Constraint

Dec 13, 2007

Here is my sqlce:




Code Block

alter table tblV
add constraint
foreign key (T_ID)
references tblT(T_ID)
on delete set null on update cascade
Error is:
Major Error 0x80040E14, Minor Error 25501
There was an error parsing the query. [ Token line number = 3,Token line offset = 1,Token in error = foreign ]

I'm new with SQL Mobile, so sorry for the novice question.

Thanks

View 5 Replies View Related

Foreign Key Constraint Conflict

Jan 21, 2007

Hi,
I am fairly new to SQL server Express and I have quite a simple database set up and I am trying to test it out with data. I have €śPain Reading€? and €śWorsen Factors€? tables with a 1: M relationship. The primary key in the Pain reading table is ReadingID which is being set using getdate() for the default value. I am getting the following error when attempting to add a new row to the €śWorsen Factors€? table:

No row was updated

The data in row 1 was not committed.
Error source:.Net SqlClient Data Provider
Error Message: The insert statement conflicted with the FOREIGN KEY constraint "FK_WorsenFactor_PainReading1". The confilct occurred in database "paindata", table "dbo.PainReading", column 'ReadingID'.
The statement has been terminated.

Any help or suggestions would be very helpful.

Thanks

View 4 Replies View Related

Creating Foreign Key Constraint

Aug 1, 2007

I have two tables; each has multi-column primary keys. I need to create a foreign key relationship between the two tables.

Sales:
DKey, int, PK
OKey,int, PK
RKey,int, PK
...

Rep:
Bkey, int, PK, identity
Rkey, int, PK
...

When I try to like Rkey from both tables as a foreign key relationship, I get an error that the columns in one table "do not match an existing primary key or UNIQUE constraint. (I've tried it both ways and get the same error.)

How can I link these two tables?

Thanks.

View 7 Replies View Related

Error FOREIGN KEY Constraint

Dec 3, 2007



Hi,
i have two tables, one is department-Table(Master table) and other is employee-table(Child table).
DNO is a data field which is common in both the table. "DNO" is primary key in department-table and "DNO" is foreign key in child table.

I am trying to insert rows in the table i found the following error:

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Employee_Department". The conflict occurred in database "Project", table "dbo.Department", column 'Dno'.

What's the solution to replace this error

Thanks.

View 4 Replies View Related

Foreign Key Constraint Issue..please Help

Oct 11, 2006

Hi there

Yesterday I made alot of updates to to various tables within a databse, to update some records I had to drop the foreign key constraint, but when I try to add the constraint back I get an error message (in red)
ALTER TABLE [dbo].[ITEMS] ADD
CONSTRAINT [FK_ITEMS__ITEM_CATEGORIES] FOREIGN KEY
(
[ITC_ID]
) REFERENCES [dbo].[ITEM_CATEGORIES] (
[ITC_ID]
) ON UPDATE CASCADE NOT FOR REPLICATION ,
CONSTRAINT [FK_ITEMS__ITEM_TYPES] FOREIGN KEY
(
[ITY_ID]
) REFERENCES [dbo].[ITEM_TYPES] (
[ITY_ID]
) ON UPDATE CASCADE NOT FOR REPLICATION
GO
Server: Msg 1785, Level 16, State 1, Line 1
Introducing FOREIGN KEY constraint 'FK_ITEMS__ITEM_CATEGORIES' on table 'ITEMS' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Server: Msg 1750, Level 16, State 1, Line 1
Could not create constraint. See previous errors

any suggestions? I tried modifying the statement to ON UPDATE NO ACTION, but I get exactly the same error message.
Any help would be much appreciated...thanks in advance

View 3 Replies View Related

Override A Foreign Key Constraint

Aug 9, 2007

A website that I'm working on has users sign in and keeps a log of the pages they go to. The log table has a foreign key in it that links to the username is the users table. I need to update the username for one of the users but the foreign key is preventing me from doing so. What is the benefit of having a foreign key like this? Can I delete it to update the username or is there a better way?

View 1 Replies View Related

Foreign Key Constraint- Reference 1 Of 2 Tables

Nov 2, 2007

Hi,
I don't know if this is possible, i believe not, so I'm here to ask the experts if is possible to have a foreign key constraint that references the key of one of two tables.
Like this:
I have 3 tables: TABLE X, TABLE A and TABLE B
Is it possible to the FK on TABLE X refernce the PK of TABLE A OR TABLE B?
If yes, how can I do this?
If not, I need to have a fourth table, so TABLE X references TABLE A and TABLE Y references TABLE B.
Thanks!

View 4 Replies View Related

Foreign Key Constraint To A Composite Primary Key

Mar 6, 2008

I have two tables: table 1 and table 2. The primary key of table is composite key of two collumns and table 2 is the child of parent table 1. Is it possible to create / define a foreign key constraint using a composite primary key?

View 10 Replies View Related

Urgent!drop Foreign Key Constraint

Mar 1, 2001

I have to drop foreign key constraint from one table. How can I do that? Is it possible?
Also,

Is it possible to add a foreign key constraint on the table once it has a data?

View 1 Replies View Related

Column Foreign Key Constraint 'EOR_ITE_REF_EOR'

Mar 17, 2004

I am importing data from a flat, comma delimited text file. It appears to properly import all the records and then on the last record it give me the error

INSERT statement conflicted with COLUMN FOREIGN KEY constraint for 'EOR_ITE_REF_EOR'.

Then it goes on to tell me the database, table and column in which the problem occured which is the first column in the table. It looks like it doesn't like the end of the file for some reason (EOR, end of record?) so I tried deleting the last record from the file and it still does it. I do have a file that I have imported that worked so I tried copying the last record of that file and pasting it into the last record of the file I wanted but that did not work either. The ends of file that works and the file that doesn't work look the same and I can find nothing on 'EOR_ITE_REF_EOR'. Any help would be appreciated.

View 1 Replies View Related

Create A Foreign Key To Unique Constraint?

Jul 3, 2015

why it is not possible to create a Foreign key to a Unique constraint?

Table A has column 1 holding a Primay key and two columns (2 and 3) holding a Unique combination (and some more columns).He created an Unique constraint on column 2 and 3 together.

He wanted to use this Unique combination to point to table B (instead of the table 1's PK) so he tried to create a foreign key on a column in table B but an error popped up prompting;

The columns in table 'TABLE_A' do not match an existing primary key or UNIQUE constraint.

Ok - these two columns ar no PK but the hold an Unique constraint......

View 2 Replies View Related

Enforcing Foreign Key Constraint On Tables

Mar 5, 2008

Greetings all!

How can I enforce a foreign key constraint when I have two tables each one residing on a different database?

Thanks for your help in advance.

View 1 Replies View Related

Determining If Foreign Key Constraint Exists

Jul 20, 2005

Hello,I'm working with a number of databases. I need a way to determine if aforeign key with given name exists and determine what tables andfields are linked to it. Any ideas?I know I can issue the following statement to get a list of the fieldsthat are constrained by a foreign key constraint.SELECT * FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGEHow can I get a list of fields pointed to by the constraints?Thanks,WillJoin Bytes!

View 1 Replies View Related

Adding A Column With Foreign Key Constraint

Oct 1, 2007



Hello!


I am trying to alter a table adding a column with foreignkey constraint. The table that holds the primary key in that relation has data, so i am not being able to execute the alter statement.

This is the error:


Server: Msg 547, Level 16, State 1, Line 1
ALTER TABLE statement conflicted with COLUMN FOREIGN KEY constraint 'FK_MOPAeroportoICAO_IDMOPAlimentacaoFerroviaTipo'. The conflict occurred in database 'MOP', table 'MOPAlimentacaoFerroviaTipo', column 'IDMOPAlimentacaoFerroviaTipo'.

This is the script:

ALTER TABLE MOPAeroportoICAO
ADD IDMOPAlimentacaoFerroviaTipo [int] DEFAULT 0 NOT NULL
CONSTRAINT [FK_MOPAeroportoICAO_IDMOPAlimentacaoFerroviaTipo] FOREIGN KEY
REFERENCES MOPAlimentacaoFerroviaTipo (IDMOPAlimentacaoFerroviaTipo)

How can i turn of check when i add the foreign key ?

Thanks in advance

View 1 Replies View Related

Problem Creating A Foreign Key Constraint

Feb 8, 2007

Hello, I'm having some problems trying to create this foreign key constraint:

ALTER TABLE dbo.t2_demaclie
ADD CONSTRAINT FK03_T2_DEMACLIE FOREIGN KEY (dclPerfilCompania, dclOrdenPedido)
REFERENCES DBO.T2_PEDIDOCLIENTE (cdPerfilCompania, nmOrdenPedido)


Server: Msg 547, Level 16, State 1, Line 1
ALTER TABLE statement conflicted with TABLE FOREIGN KEY constraint 'FK03_T2_DEMACLIE'. The conflict occurred in database 'Comfruta_dllo', table 't2_pedidoCliente'.



I'm sure there's no other constraint with the same name, and there's no othe one with the same columns...


Thanks a lot !!

View 6 Replies View Related

Programatically Finding If A Row Has A Foreign Key Constraint

Jul 11, 2006

Hello,

Does anyone know a way from within a .net application to find out if a row has a foreign key constraint before updating it? Or possibly in a SQL Stored Procedure if necessary.

What I am trying to do is basicly simulate a delete of a row in a SQL 2005 database from a .net application. Instead of actually deleting the row I want to set a bool column as deleted. The problem is that I can't orphan records that have a relationship to the one deleted.

This is normaly taken care of automaticly with refrential integrity working properly, but not actually calling delete comands I can't seem to find that out without writing a lot of code to check manually in other tables for that key.

Any help would be appreciated greatly,

Thanks,

Patrick

View 3 Replies View Related

INSERT Statement Conflicted With The FOREIGN KEY Constraint

Mar 7, 2008

Hello Friends
           How are you?? Friends i am getting problem in SQL Server 2005. I am deployng web application on production server as well as Databse also. In production server i inserted new field in all tables which is rowguid and its type is uniqueidentifier. The default binding for this field is newsequentialid(). In some pages it works ok but in some places it generates error like which is describe below:
Error:
System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_TransactionDetails_TransactionMain". The conflict occurred in database "dbname", table "dbo.TransactionMain", column 'TransactionMainID'. The INSERT statement conflicted with the FOREIGN KEY constraint "FK_TransactionDetails_TransactionMain". The conflict occurred in database "dbname", table "dbo.TransactionMain", column 'TransactionMainID'. The INSERT statement conflicted with the FOREIGN KEY constraint "FK_TransactionDetails_TransactionMain". The conflict occurred in database "dbname", table "dbo.TransactionMain", column 'TransactionMainID'. The INSERT statement conflicted with the FOREIGN KEY constraint "FK_TransactionDetails_TransactionMain". The conflict occurred in database "dbname", table "dbo.TransactionMain", column 'TransactionMainID'. The INSERT statement conflicted with the FOREIGN KEY constraint "FK_TransactionDetails_TransactionMain". The conflict occurred in database "dbname", table "dbo.TransactionMain", column 'TransactionMainID'. The statement has been terminated. The statement has been terminated. The statement has been terminated. The statement has been terminated. The statement has been terminated. at MyGeneration.dOOdads.BusinessEntity.LoadFromSql(String sp, ListDictionary Parameters, CommandType commandType) at MyGeneration.dOOdads.BusinessEntity.LoadFromSql(String sp, ListDictionary Parameters) at LCO.pname.DAL.BLL.AccountInfo.funName(Parameters) 
In above mentioned error, foreign key is availabe in child table. Can anybody help me to solve this problem. Its urgent so plz reply me as soon as possible. I'll be very thankfull to you. Thanks in Advance.
 Regards,

View 1 Replies View Related

INSERT Statement Conflicted With COLUMN FOREIGN KEY Constraint...

Feb 18, 2006

Hi there,
I have a stored procedure which i pass a number of parameters into. One of these parameters is staffNo (only passed this in because i couldn't execute the query without it). The thing is this field can be Null, but when trying to pass null into it it comes up with an Foreign Key conflict. staffNo is a foreign key within the table i'm inserting the data into.
This is the error i get:
"INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'PropStaffFK'. The conflict occurred in database 'DewMountain', table 'TblStaff', column 'staffNo'. The statement has been terminated. The 'PropertyAdvert' procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead. "
 
Does anyone know of away around this? how to pass a null value to the stored procedure without it causing this error.
Thank you
Melanie

View 13 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved