删除2个表的级联? [英] delete cascade for 2 tables?

查看:78
本文介绍了删除2个表的级联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有人,


我想知道是否有人可以提供有关如何创建使用删除级联来删除2个表中的记录的存储过程的教程或示例?我在网上看到了一些例子,但我在网上找到的例子只显示了两个表是否有共同字段的例子。我的2张桌子彼此没有任何共同之处。两者都是自己的表中的主键。现在这里是删除的内容。我正在使用SQL Server 2005.


Hey Everyone,

I was wondering if anyone could provide a tutorial or example on how to create a stored procedure that uses delete cascade to delete records from 2 tables? i have seen examples online, but the ones i found online only show examples for if both tables have a field in common. My 2 tables have nothing in common with each other. An both are primary keys in there own table.Right now here is what i have for delete.I am using SQL Server 2005.


展开 | 选择 | Wrap | 行号

推荐答案

你确定它们没有任何共同之处吗?如果许多部件属于一个序列,那么你肯定会有一个链接两个的外键吗?
Are you sure that they have nothing in common? If many parts belong to a serial then surely you''d have a foreign key that links the two?



你确定他们什么都没有共同点?如果许多部件属于一个序列,那么你肯定会有一个链接两者的外键吗?
Are you sure that they have nothing in common? If many parts belong to a serial then surely you''d have a foreign key that links the two?



Hey Acoder,


嗯,事情是他们没有关系。两者完全分开..但他们都持有相同的数字。因此,如果pkb_fk_ticketNo的值为1,那么fk_ticketNo。但是虽然它们具有相同的价值,但它们没有相同的字段名称。在示例中,我看到他们展示的一个示例是两个表都具有字段名称ID。然而,我的并不是他们有2个不同的名字。我知道两个领域不一定要有相同的名字来建立关系。但我知道这些领域并不存在这样的关系。因为如果我去插入我的表单fk_ticketNo不能正常工作,pkb_fk_ticketNo仍然可以使用或不使用fk_ticketNo.I希望这样做,因为我不是那个自己创建表的人。 br />

谢谢,

Rach

Hey Acoder,

Well the thing is they don''t have a relationship together. There both completely seperated.. But they both do hold the same number. So if pkb_fk_ticketNo has the value of 1 so will fk_ticketNo . But although they hold the same value they don''t have the same field name in common. Like in the examples i saw one example they showed was both tables had the field name ID. However, mine are not like that they have 2 different names.An i know that both fields don''t have to have the same name to have a relationship. But i know for a fact these fields don''t share a relationship. Because if i go to insert my form an fk_ticketNo don''t work right, pkb_fk_ticketNo will still work right with or without fk_ticketNo.I hope that makes since, its hard to explain since i am not the one that created the tables myself.

Thank you,
Rach


如果我理解正确,一张票有很多系列,每个系列有很多部件。如果是这样,那么部件不应该有指向票证的外键,它应该是串行的。在包含与串行主键匹配的外键的部分中是否有字段?
If I understand correctly, a ticket has many serials and each serial has many parts. If so, then parts should not have the foreign key pointing to ticket, it should be for serial. Do you have a field in parts containing the foreign key that matches the primary key of serial?


这篇关于删除2个表的级联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆