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.
| Author |
Topic |
|
thaniparthi.rao
Yak Posting Veteran
96 Posts |
Posted - 2008-06-13 : 01:16:21
|
| I have 2 tables.Table 1 and table 2.Table 1 has a foreign key related to a particular column on table 2.Suppose if i have applied a truncate command on table 2 .will it work or not.We have to check for dependencies on the table before we should apply a truncate command. Could any one tell me can we directly apply a truncate command on any object irrespective of the dependencies on that object. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-13 : 01:18:51
|
| Nope. you cant truncate a table which is referenced by foreign key constraint. however you can delete records using delete statement which are not referenced in the second table. |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-06-13 : 01:37:10
|
quote: Originally posted by thaniparthi.rao I have 2 tables.Table 1 and table 2.Table 1 has a foreign key related to a particular column on table 2.Suppose if i have applied a truncate command on table 2 .will it work or not.We have to check for dependencies on the table before we should apply a truncate command. Could any one tell me can we directly apply a truncate command on any object irrespective of the dependencies on that object.
One way is drop that foreign key constraint and truncate table2 and recreate the same foreign key constraint on table 1 |
 |
|
|
|
|
|