2014-09-26 50 views

回答

1

這應該這樣做:

declare @syn nvarchar(30) 
declare @temp1 nvarchar(30) 
declare read_cur cursor for select distinct name from sys.synonyms where is_ms_shipped = 0 

open read_cur 
fetch read_cur into @syn 
while @@fetch_status = 0 
begin 
     --select read_cur into @temp1 
     set @temp1='drop synonym '[email protected] 
     exec sp_executesql @temp1 

     fetch read_cur into @syn 
end 
close read_cur 
deallocate read_cur 
+0

是的,這對我的作品,但可以肯定我刪除所需的架構我修改後的代碼只同義詞:「降代名詞my_schema」設置@ temp1目錄= + @syn 因爲我不想從另一個模式刪除同義詞,只是my_schema。非常感謝! – codelikeprogrammerwoman 2014-09-26 06:39:11