Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

can't truncate table due to FK (none exists)

4 posts in General Discussion Last posting was on 2011-02-11 22:02:31.0Z
rick_806 Posted on 2011-02-11 19:16:54.0Z
Sender: 4af.4d5011e8.1804289383@sybase.com
From: rick_806
Newsgroups: sybase.public.ase.general
Subject: can't truncate table due to FK (none exists)
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4d558b26.4bdb.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 11 Feb 2011 11:16:54 -0800
X-Trace: forums-1-dub 1297451814 10.22.241.41 (11 Feb 2011 11:16:54 -0800)
X-Original-Trace: 11 Feb 2011 11:16:54 -0800, 10.22.241.41
Lines: 13
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29958
Article PK: 79187

ASE 15.5

I can't truncate a table due to the error "Could not
truncate table 'Customer' because there are referential
constraints defined on it and there are data rows in some of
the referencing tables.". I don't understand this as the
table has a primary key defined but no foreign keys? Other
tables that display this message always have a foreign key
in another table. Is there some other issue that will
produce this message? The table has 1 clustered index.

Thx,
rick_806


Sherlock, Kevin [TeamSybase] Posted on 2011-02-11 19:22:37.0Z
From: "Sherlock, Kevin [TeamSybase]" <kevin.sherlock@teamsybase.com>
Newsgroups: sybase.public.ase.general
References: <4d558b26.4bdb.1681692777@sybase.com>
Subject: Re: can't truncate table due to FK (none exists)
Lines: 23
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4d558c7d$1@forums-1-dub>
Date: 11 Feb 2011 11:22:37 -0800
X-Trace: forums-1-dub 1297452157 10.22.241.152 (11 Feb 2011 11:22:37 -0800)
X-Original-Trace: 11 Feb 2011 11:22:37 -0800, vip152.sybase.com
X-Authenticated-User: teamsybase
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29959
Article PK: 79186

exec sp_depends mytable_that_i_want_to_truncate


should show all foreign key definitions tied to your primary key. Are you
saying that you tried this and don't ssee any dependencies?

<rick_806> wrote in message news:4d558b26.4bdb.1681692777@sybase.com...
> ASE 15.5
>
> I can't truncate a table due to the error "Could not
> truncate table 'Customer' because there are referential
> constraints defined on it and there are data rows in some of
> the referencing tables.". I don't understand this as the
> table has a primary key defined but no foreign keys? Other
> tables that display this message always have a foreign key
> in another table. Is there some other issue that will
> produce this message? The table has 1 clustered index.
>
> Thx,
> rick_806


rick_806 Posted on 2011-02-11 20:43:54.0Z
Sender: 4af.4d5011e8.1804289383@sybase.com
From: rick_806
Newsgroups: sybase.public.ase.general
Subject: Re: can't truncate table due to FK (none exists)
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4d559f8a.4e89.1681692777@sybase.com>
References: <4d558c7d$1@forums-1-dub>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 11 Feb 2011 12:43:54 -0800
X-Trace: forums-1-dub 1297457034 10.22.241.41 (11 Feb 2011 12:43:54 -0800)
X-Original-Trace: 11 Feb 2011 12:43:54 -0800, 10.22.241.41
Lines: 75
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29960
Article PK: 79189

I used SybCen, the folder for foreign keys is empty. I'm not
sure how to read the output below? Should I accept the
statement that "object has no refs and no objects ref it"?
Or should I be looking at the list as shown below?

sp_depends 'Customer'

Object doesn't reference any object and no objects reference
it.

Dependent objects that reference all columns in the table.
Use sp_depends on each column to get more information.
Columns referenced in stored procedures, views or triggers
are not included in this report.

Execution time: 5.023 seconds

Column,Type,Object Names or Column Names
'custId','foreign key reference','custSite on CSite'
'custId','foreign key reference','custUser on CEcUser'
'custId','foreign key reference','custGroup on CGroups'
'custId','foreign key reference','RefCustomer41 on CRates'
'custId','foreign key reference','RefCustomer30 on
CTransactions'
'custId','foreign key reference','RefCustomer42 on
DCustomerConfig'
'custId','foreign key reference','RefCustomer11 on
CDistributionSchedule'
'custId','foreign key reference','RefCustomer47 on
CDistributionRequests'
'custId','index','PKCustId (custId)'
'custId','logical RI','Customer (custId)'
'custId','logical RI','From RSite (custId) To Customer
(custId)'
'custId','logical RI','From RRates (custId) To Customer
(custId)'
'custId','logical RI','From REcUser (custId) To Customer
(custId)'
'custId','logical RI','From RGroups (custId) To Customer
(custId)'
'custId','logical RI','From RTransactions (custId) To
Customer (custId)'
'custId','logical RI','From RDistributionSchedule (custId)
To Customer (custId)'
'custId','statistics','(custId)'
'custName','index','customerKey (custName)'
'custName','statistics','(custName)'

> exec sp_depends mytable_that_i_want_to_truncate
>
>
> should show all foreign key definitions tied to your
> primary key. Are you saying that you tried this and
> don't ssee any dependencies?
>
>
> <rick_806> wrote in message
> > news:4d558b26.4bdb.1681692777@sybase.com... ASE 15.5
> >
> > I can't truncate a table due to the error "Could not
> > truncate table 'Customer' because there are referential
> > constraints defined on it and there are data rows in
> > some of the referencing tables.". I don't understand
> > this as the table has a primary key defined but no
> > foreign keys? Other tables that display this message
> > always have a foreign key in another table. Is there
> > some other issue that will produce this message? The
> table has 1 clustered index. >
> > Thx,
> > rick_806
>
>


jobless Posted on 2011-02-11 22:02:31.0Z
Sender: 313a.4d515ce9.1804289383@sybase.com
From: jobless
Newsgroups: sybase.public.ase.general
Subject: Re: can't truncate table due to FK (none exists)
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4d55b1f7.50be.1681692777@sybase.com>
References: <4d558b26.4bdb.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 11 Feb 2011 14:02:31 -0800
X-Trace: forums-1-dub 1297461751 10.22.241.41 (11 Feb 2011 14:02:31 -0800)
X-Original-Trace: 11 Feb 2011 14:02:31 -0800, 10.22.241.41
Lines: 17
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:29961
Article PK: 79193


> ASE 15.5
>
> I can't truncate a table due to the error "Could not
> truncate table 'Customer' because there are referential
> constraints defined on it and there are data rows in some
> of the referencing tables.". I don't understand this as
> the table has a primary key defined but no foreign keys?
> Other tables that display this message always have a
> foreign key in another table. Is there some other issue
> that will produce this message? The table has 1 clustered
> index.
>
> Thx,
> rick_806

I typically run sp_helpconstraint <objectname> to check any
constraint.