我想从特定的模式中删除同义词,比如:
drop synonym where schema like 'my_schema'
或
drop synonym where name = my_schema.*
或者类似的事情?有可能吗?
这应该做:
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 '+@syn
exec sp_executesql @temp1
fetch read_cur into @syn
end
close read_cur
deallocate read_cur