链接服务器和约束SQL 2005

时间:2021-11-14 02:57:36

Does anyone know if you can drop a constraint on a table via a linked server in SQL 2005

有谁知道你是否可以通过SQL 2005中的链接服务器删除表上的约束

2 个解决方案

#1


Can you have a Foreign Key onto a View of a Linked Server table in SQLServer 2k5?

你可以在SQLServer 2k5的一个链接服务器表的视图上有一个外键吗?

I would say you can not.

我会说你做不到。

#2


You can, but you have to use some dynamic SQL trickery to make it happen.

你可以,但你必须使用一些动态SQL技巧来实现它。

declare @cmd VARCHAR(4000)
SET @cmd = 'Use YourDatabase
ALTER TABLE YourTable
DROP CONSTRAINT YourConstraint'

exec YourServer.master.dbo.sp_executesql @SQL

#1


Can you have a Foreign Key onto a View of a Linked Server table in SQLServer 2k5?

你可以在SQLServer 2k5的一个链接服务器表的视图上有一个外键吗?

I would say you can not.

我会说你做不到。

#2


You can, but you have to use some dynamic SQL trickery to make it happen.

你可以,但你必须使用一些动态SQL技巧来实现它。

declare @cmd VARCHAR(4000)
SET @cmd = 'Use YourDatabase
ALTER TABLE YourTable
DROP CONSTRAINT YourConstraint'

exec YourServer.master.dbo.sp_executesql @SQL