?? 比較兩個數據庫中的視圖&存儲過程的結構.sql
字號:
/*--數據結構比較
比較兩個數據庫中的視圖/存儲過程的結構(結構比較,不是功能比較)
--鄒建 2004.07(引用請保留此信息)--*/
/*--調用示例
--調用
exec p_compdb 'pubs','northwind'
--*/
create proc p_compdb
@db1 sysname, --第一個庫
@db2 sysname --第二個庫
as
exec('
select 類型=case isnull(a.xtype,b.xtype) when ''V'' then ''視圖'' else ''存儲過程'' end
,匹配情況=case
when a.name is null then ''庫 ['+@db1+'] 中無''
when b.name is null then ''庫 ['+@db2+'] 中無''
else ''結構不同'' end
,對象名稱=isnull(a.name,b.name)
from(
select a.name,a.xtype,b.colid,b.text
from ['+@db1+']..sysobjects a,['+@db1+']..syscomments b
where a.id=b.id and a.xtype in(''V'',''P'') and a.status>=0
)a full join(
select a.name,a.xtype,b.colid,b.text
from ['+@db2+']..sysobjects a,['+@db2+']..syscomments b
where a.id=b.id and a.xtype in(''V'',''P'') and a.status>=0
)b on a.name=b.name and a.xtype=b.xtype and a.colid=b.colid
where a.name is null
or b.name is null
or isnull(a.text,'''')<>isnull(b.text,'''')
group by a.name,b.name,a.xtype,b.xtype
order by 類型,匹配情況,對象名稱')
go
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -