Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 foreign key error

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2010-05-14 : 11:25:36
Iam having only read permission on my database in SI Environment

i need to simulate foreign key constraint error which
occured in production to my SI Environment(Read permisssion only i have)

how do i simulate?

Done so far :

CREATE TABLE #PARENT
(
pid int not null constraint pk primary key
)

Create table #child
(
cid int not null constraint pk1 primary key,
pid int not null constraint fk foreign key references #parent(pid)
)


error occurred :
Skipping FOREIGN KEY constraint 'fk' definition for temporary table.

X002548
Not Just a Number

15586 Posts

Posted - 2010-05-14 : 11:41:43
you need to read the rest

Skipping FOREIGN KEY constraint 'fk' definition for temporary table.

FOREIGN KEY constraints are not enforced
on local or global temporary tables.

Which is pretty much self explanatory



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2010-05-14 : 11:59:06
ok. so foreign key reference cannot be created on local/global temporary table..then how can i do for simulate the error
quote:
Originally posted by X002548

you need to read the rest

Skipping FOREIGN KEY constraint 'fk' definition for temporary table.

FOREIGN KEY constraints are not enforced
on local or global temporary tables.

Which is pretty much self explanatory



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam





Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-14 : 12:05:51
If you don't have the needed permission then why should it be your job?
Ask someone who has the needed permission instead of working around for hours


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-05-14 : 12:54:51
Well can you even do a create temp table with out the right permission?


Can you do this?

CREATE TABLE PARENT
(
pid int not null constraint pk primary key
)

Create table child
(
cid int not null constraint pk1 primary key,
pid int not null constraint fk foreign key references #parent(pid)
)



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2010-05-14 : 13:54:19
they have given only db_DataReader role. so i can't create main table.but i can create temp table

quote:
Originally posted by X002548

Well can you even do a create temp table with out the right permission?


Can you do this?

CREATE TABLE PARENT
(
pid int not null constraint pk primary key
)

Create table child
(
cid int not null constraint pk1 primary key,
pid int not null constraint fk foreign key references #parent(pid)
)



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam





Go to Top of Page
   

- Advertisement -