惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
量子位
GbyAI
GbyAI
腾讯CDC
T
Tailwind CSS Blog
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
D
Docker
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
N
Netflix TechBlog - Medium
Jina AI
Jina AI
IT之家
IT之家
Y
Y Combinator Blog

博客园 - stu_acer

对C#对象的Shallow、Deep Cloning认识【转】 PowerShell 启动应用程序【转】 把boolean 参数放到最后面(Put boolean arguments last)【转载】 几个收藏的根据数据库生成Insert语句的存储过程[修正版] IE6下PNG图片透明显示解决方法(From QQ) 用Regex类计算一个字符串出现次数是最好方法【转载】 C#有关Session 操作的几个误区【转】 - stu_acer - 博客园 DataList绑定数据到泛型类(Dictionary) 【转】 重写Asp.NET2.0 TreeView的折叠/展开方法(TreeView_ToggleNode) javascript window.close() 去掉那讨厌的确认对话框【转】 thickbox使用技巧【转】 - stu_acer - 博客园 jQuery操作checkbox的例子(全选,反选,获取选取值)【转】 查看SQL Server 2005版本号 创建SQL索引,查看SQL性能语句收集 ddlevelsmenu在IE6下,与select冲突的解决办法【整理】 IE6 Select元素无法被div等元素覆盖的bug解决办法【zz】 利用Attribute和反射从模板生成短信 - stu_acer - 博客园 Session & Cookie 的使用建议(zz) - stu_acer AdventureWorks、Northwind、pubs示例数据库下载
SQL Server删除外键约束
stu_acer · 2010-08-02 · via 博客园 - stu_acer

来源:http://zhidao.baidu.com/question/150790965

x先找出约束名字
然后删除它
我给个例子
--测试环境
--
主表
create table test1(id int primary key not null,value int)
insert test1 select 1,2
go
--从表
create table test2(id int references test1(id),value int)
go
--第一步:找出test2表上的外键约束名字
--
2000
exec sp_helpconstraint 'test2'
--可以在constraint_name 属性中找到外键约束名字
--
2005
select name
from sys.foreign_key_columns f join sys.objects o on f.constraint_object_id=o.object_id
where f.parent_object_id=object_id('test2')
/*
name
---------------------------------
FK__test2__id__08EA5793
*/--第二步:删除外键约束
alter table test2 drop constraint FK__test2__id__08EA5793 --第三步:检查表上是否还有外键约束
--
只要使用第一步里面的查找语句即可