开发者

How to get FK script from existing tables in SQL server?

开发者 https://www.devze.com 2023-04-13 08:23 出处:网络
Suppose I have many tables which have Foreign keys created. I want to get o开发者_开发问答nly the scripts for those FKs like so:

Suppose I have many tables which have Foreign keys created.

I want to get o开发者_开发问答nly the scripts for those FKs like so:

ALTER TABLE dbo.MyTable ADD CONSTRAINT...

I've tried to use tools from Studio management, however, it returns the script and create table together. I only want to return the FK scripts.

How can I return only the FK scripts from an SQL table?


If you're using Management Studio, expand the Keys tree of the table you want to script for, right-click the Foreign Key and choose Script key as... CREATE from the menu.

0

精彩评论

暂无评论...
验证码 换一张
取 消