declare @name varchar(500),@type varchar(10),@tbName varchar(500)

DECLARE cur CURSOR STATIC                
FOR
select s.name,s.xtype,p.name tbName from sysobjects p inner join sysobjects s on s.parent_obj=p.id
where p.name like 'SC_T_%'
order by p.name

OPEN cur                                
WHILE 1=1
    BEGIN
    FETCH NEXT FROM cur INTO @name,@type,@tbName    
    if( @@fetch_status <> 0 ) break;            
        exec ('alter table '+@tbName+' drop constraint '+@name)
    END
CLOSE cur                                

deallocate  cur
 

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐