2012-05-19 20 views
0

我正在運行以下查詢,並且由於生產數據庫正在使用複製,因此我們正在獲取結果中爲複製添加的所有表(例如MSpeer_conflictdetectionconfigrequest,MSpeer_conflictdetectionconfigresponse)。如何排除從sysobjects中選擇複製表

SELECT name FROM sysobjects WHERE type='U' AND name != 'sysdiagrams' 

我們需要調整這個查詢,以便這些表不顯示出來。我當然可以做一個name NOT IN()並列出他們全部,但我正在尋找一個更好的解決方案。

感謝您的幫助。

回答

0

由於您使用的SQL 2008,我建議將FF:

select * from sys.tables where is_ms_shipped = 0 
+0

請問這項工作在2005年呢? –

+0

查看SQL 2005 for sys.objects的文檔,它看起來像is_ms_shipped列存在,所以它應該。 –

0
SELECT name . 
FROM sysobjects 
WHERE type='U' 
    AND name != 'sysdiagrams' 
    AND replinfo = 0 

但是: http://msdn.microsoft.com/en-us/library/ms177596.aspx注意,系統對象和replinfo似乎過時。

0=not replicated 
128 = merge - table or indexed view 
1=transactional - table or indexed view - log based 
3=transactional - table or indexed view - log based with custom sync object 
33=transactional - table or indexed view - immediate updating 

35=transaction- table or indexed view - log based with custom sync object 
and custom filter 
129 =merge and transactional - table or indexed view 

64 - procs used by immediate updating 
512 - all other procsprocs, views, functions