冰镇可乐 发表于 2016-11-5 08:37:20

How to forcely drop tables in SQL Server 2008

This script can drop a SQL Server table. It automaticly remove all the constraints of the table before the drop query.

先删除所有constraints
declare @sql varchar(1024)
declare curs cursor for
select 'ALTER TABLE "'+tab.name+'" DROP CONSTRAINT '+cons.name
from sys.objects cons,sys.objects tab
where cons.type in ('C', 'F', 'PK', 'UQ', 'D')
and cons.parent_object_id=tab.object_id and tab.type='U'
order by cons.type
open curs
fetch next from curs into @sql
while (@@fetch_status = 0)
begin
print @sql
exec(@sql)
fetch next from curs into @sql
end
close curs
deallocate curs

然后删除所有tables
declare @sql varchar(1024)
declare curs cursor for
select 'DROP TABLE "'+tab.name+'";'
from sys.objects cons,sys.objects tab
where cons.type in ('C', 'F', 'PK', 'UQ', 'D')
and cons.parent_object_id=tab.object_id and tab.type='U'
order by cons.type
open curs
fetch next from curs into @sql
while (@@fetch_status = 0)
begin
print @sql
exec(@sql)
fetch next from curs into @sql
end
close curs

或者用下列方式
declare @c int begin
begin if object_id('ADMINCONFIG_SUPERGROUPS') is not null begin drop table end SET @c = 0;end
begin if object_id('ADMINCONFIG_SUPERUSERS') is not null begin drop table end SET @c = 0;end
begin if object_id('ADMINCONFIG') is not null begin drop table end SET @c = 0;end
begin if object_id('AMFAPPLICATIONREVISION') is not null begin drop table end SET @c = 0;end
begin if object_id('AMXADMINUSERPREFERENCES') is not null begin drop table end SET @c = 0;end
begin if object_id('AMXDMINSRPRFRENCES_PRPERTYGRPS') is not null begin drop table end SET @c = 0;end
begin if object_id('APPENDERREF') is not null begin drop table end SET @c = 0;end
begin if object_id('APPFRAGMENT') is not null begin drop table end SET @c = 0;end
begin if object_id('APPLICATIONFOLDER') is not null begin drop table end SET @c = 0;end
begin if object_id('APPLICATION') is not null begin drop table end SET @c = 0;end
begin if object_id('BASECOMPONENT_APPFRAGMENTS') is not null begin drop table end SET @c = 0;end
begin if object_id('BASECOMPONENT_POLICYINTENTS') is not null begin drop table end SET @c = 0;end
begin if object_id('BASECOMPONENT') is not null begin drop table end SET @c = 0;end
begin if object_id('BINDING_APPFRAGMENTS') is not null begin drop table end SET @c = 0;end
begin if object_id('BINDING_APPLICATIONLOGGERS') is not null begin drop table end SET @c = 0;end
begin if object_id('BINDING_INCLUDEDRESOURCES') is not null begin drop table end SET @c = 0;end
begin if object_id('BINDING_NODELOGGERS') is not null begin drop table end SET @c = 0;end
begin if object_id('BINDING_PARENTSOURCECOMPONENT') is not null begin drop table end SET @c = 0;end
begin if object_id('BINDING_POLICYINTENTS') is not null begin drop table end SET @c = 0;end
begin if object_id('BINDING_SVARSUSED') is not null begin drop table end SET @c = 0;end
begin if object_id('BINDING') is not null begin drop table end SET @c = 0;end
begin if object_id('BNDING') is not null begin drop table end SET @c = 0;end
begin if object_id('BUNDLELIST') is not null begin drop table end SET @c = 0;end
begin if object_id('CAPABILITYLINK') is not null begin drop table end SET @c = 0;end
begin if object_id('CAPABILITYPROPAGATION') is not null begin drop table end SET @c = 0;end
begin if object_id('CERTIFICATE') is not null begin drop table end SET @c = 0;end
begin if object_id('CLUSTER_HOSTS') is not null begin drop table end SET @c = 0;end
begin if object_id('CMPNNTINSTNCE_DEPENDSNCMPNENTS') is not null begin drop table end SET @c = 0;end
begin if object_id('CMPNNTNSTNC_DPNDSNCMPNNTSCRSSN') is not null begin drop table end SET @c = 0;end
begin if object_id('COMPONENTINSTANCESET_ITEMS') is not null begin drop table end SET @c = 0;end
begin if object_id('COMPONENTINSTANCESET') is not null begin drop table end SET @c = 0;end
begin if object_id('COMPONENTINSTANCE') is not null begin drop table end SET @c = 0;end
begin if object_id('COMPONENTSUMMARY') is not null begin drop table end SET @c = 0;end
begin if object_id('COMPONENT_APPLICATIONLOGGERS') is not null begin drop table end SET @c = 0;end
begin if object_id('COMPONENT_NODELOGGERS') is not null begin drop table end SET @c = 0;end
begin if object_id('CONTEXTPARAMETERS') is not null begin drop table end SET @c = 0;end
begin if object_id('CPBILITYLINK_REQIREDCMPNENTRIS') is not null begin drop table end SET @c = 0;end
begin if object_id('CPBLTYLNK_RQRDCMPNNTRISCRSSNDS') is not null begin drop table end SET @c = 0;end
begin if object_id('CREDENTIALSERVERCONFIG') is not null begin drop table end SET @c = 0;end
begin if object_id('CREDENTIALSERVER') is not null begin drop table end SET @c = 0;end
begin if object_id('CSR') is not null begin drop table end SET @c = 0;end
begin if object_id('DEBUGGEROBJECT') is not null begin drop table end SET @c = 0;end
begin if object_id('DEPLOYMENTCONSTRAINT') is not null begin drop table end SET @c = 0;end
begin if object_id('ENDPINT_DPNDSNCMPNENTSCRSSNDES') is not null begin drop table end SET @c = 0;end
begin if object_id('ENDPOINT_DEPENDSONCOMPONENTS') is not null begin drop table end SET @c = 0;end
begin if object_id('ENDPOINT') is not null begin drop table end SET @c = 0;end
begin if object_id('ENTERPRISECREDENTIALSERVER') is not null begin drop table end SET @c = 0;end
begin if object_id('ENVIRONMENT_HOSTS') is not null begin drop table end SET @c = 0;end
begin if object_id('ENVIRONMENT_RESOURCETEMPLATES') is not null begin drop table end SET @c = 0;end
begin if object_id('ENVIRONMENT') is not null begin drop table end SET @c = 0;end
begin if object_id('ERRORDETAIL') is not null begin drop table end SET @c = 0;end
begin if object_id('EXTENSIONPOINTTYPE') is not null begin drop table end SET @c = 0;end
begin if object_id('EXTENSIONTYPE') is not null begin drop table end SET @c = 0;end
begin if object_id('FEATUREID') is not null begin drop table end SET @c = 0;end
begin if object_id('FEATURELIST') is not null begin drop table end SET @c = 0;end
begin if object_id('FILTERSECTIONGROUP') is not null begin drop table end SET @c = 0;end
begin if object_id('FILTERSECTION') is not null begin drop table end SET @c = 0;end
begin if object_id('GADGETCOLUMN') is not null begin drop table end SET @c = 0;end
begin if object_id('HOSTTRANSPORT') is not null begin drop table end SET @c = 0;end
begin if object_id('JAVAPROCESSCONFIG') is not null begin drop table end SET @c = 0;end
begin if object_id('JCACONFIG') is not null begin drop table end SET @c = 0;end
begin if object_id('KEYSTORE') is not null begin drop table end SET @c = 0;end
begin if object_id('KEYVALUEPAIR') is not null begin drop table end SET @c = 0;end
begin if object_id('LOGAPPENDER_SVARSUSED') is not null begin drop table end SET @c = 0;end
begin if object_id('LOGGERCONFIG') is not null begin drop table end SET @c = 0;end
begin if object_id('LOGICALNODE_BINDINGS') is not null begin drop table end SET @c = 0;end
begin if object_id('LOGICALNODE_COMPONENTS') is not null begin drop table end SET @c = 0;end
begin if object_id('LOGICALNODE_PHYSICALNODES') is not null begin drop table end SET @c = 0;end
begin if object_id('LOGICALNODE') is not null begin drop table end SET @c = 0;end
begin if object_id('MACHINE') is not null begin drop table end SET @c = 0;end
begin if object_id('NAMEDRESOURCEINSTANCE') is not null begin drop table end SET @c = 0;end
begin if object_id('NDE') is not null begin drop table end SET @c = 0;end
begin if object_id('NODETEMPLATE') is not null begin drop table end SET @c = 0;end
begin if object_id('NODETYPEFEATURELIST') is not null begin drop table end SET @c = 0;end
begin if object_id('NODE_APPFRAGMENTS') is not null begin drop table end SET @c = 0;end
begin if object_id('NODE') is not null begin drop table end SET @c = 0;end
begin if object_id('NOTIFICATIONTRANSPORT') is not null begin drop table end SET @c = 0;end
begin if object_id('OBJECTTYPECLMNS_IDPRPERTYNAMES') is not null begin drop table end SET @c = 0;end
begin if object_id('OBJECTTYPECOLUMNS') is not null begin drop table end SET @c = 0;end
begin if object_id('PERMISSION') is not null begin drop table end SET @c = 0;end
begin if object_id('PLATFORM_NODES') is not null begin drop table end SET @c = 0;end
begin if object_id('PLATFORM_PERMISSIONS') is not null begin drop table end SET @c = 0;end
begin if object_id('PLATFORM') is not null begin drop table end SET @c = 0;end
begin if object_id('PLUGINCOMPONENT') is not null begin drop table end SET @c = 0;end
begin if object_id('PLUGINFEATURE') is not null begin drop table end SET @c = 0;end
begin if object_id('PLUGINSTATEONNODE') is not null begin drop table end SET @c = 0;end
begin if object_id('PLUGINTYPE1') is not null begin drop table end SET @c = 0;end
begin if object_id('POLICYSET') is not null begin drop table end SET @c = 0;end
begin if object_id('PRDPPAPPLICTIN_DISTRIBTEDTAPPS') is not null begin drop table end SET @c = 0;end
begin if object_id('PREVIOUSENVSELECTION') is not null begin drop table end SET @c = 0;end
begin if object_id('PROMOTEDSERVICE') is not null begin drop table end SET @c = 0;end
begin if object_id('PROPERTYAMF') is not null begin drop table end SET @c = 0;end
begin if object_id('PROVIDEDCAPABILITY') is not null begin drop table end SET @c = 0;end
begin if object_id('PRPGTNFRMMPLMNTTNTY_PRVDDVRSNS') is not null begin drop table end SET @c = 0;end
begin if object_id('PRPGTNFRMXTNSNPNT_PRVIDDVRSINS') is not null begin drop table end SET @c = 0;end
begin if object_id('PUBLICATIONERROR') is not null begin drop table end SET @c = 0;end
begin if object_id('PUBLICATION') is not null begin drop table end SET @c = 0;end
begin if object_id('REFERENCE_OPERATIONS') is not null begin drop table end SET @c = 0;end
begin if object_id('REFERENCE_POLICYINTENTS') is not null begin drop table end SET @c = 0;end
begin if object_id('REFERENCE_PROMOTES') is not null begin drop table end SET @c = 0;end
begin if object_id('REFERENCE') is not null begin drop table end SET @c = 0;end
begin if object_id('RELEASEUNITDEPENDENCY') is not null begin drop table end SET @c = 0;end
begin if object_id('REQUIREDCAPABILITY_WITHS') is not null begin drop table end SET @c = 0;end
begin if object_id('REQUIREDCAPABILITY') is not null begin drop table end SET @c = 0;end
begin if object_id('RESADAPTERRARASSOCIATIONS') is not null begin drop table end SET @c = 0;end
begin if object_id('RESORCEINSTANCE_ATOCREATEDREFS') is not null begin drop table end SET @c = 0;end
begin if object_id('RESORCETEMPLATE_ATOCREATEDREFS') is not null begin drop table end SET @c = 0;end
begin if object_id('RESOURCEADAPTERLIST') is not null begin drop table end SET @c = 0;end
begin if object_id('RESOURCEINSTANCE') is not null begin drop table end SET @c = 0;end
begin if object_id('RESOURCETEMPLATE_DEPENDENCIES') is not null begin drop table end SET @c = 0;end
begin if object_id('RESOURCETEMPLATE_SVARSUSED') is not null begin drop table end SET @c = 0;end
begin if object_id('RESOURCETEMPLATE') is not null begin drop table end SET @c = 0;end
begin if object_id('SBSTITUTIONVARIABLE_VISIBILITY') is not null begin drop table end SET @c = 0;end
begin if object_id('SERVERCFG_PUBLICATIONS') is not null begin drop table end SET @c = 0;end
begin if object_id('SERVERCFG') is not null begin drop table end SET @c = 0;end
begin if object_id('SERVICEVIRTUALIZATION') is not null begin drop table end SET @c = 0;end
begin if object_id('SERVICE_OPERATIONS') is not null begin drop table end SET @c = 0;end
begin if object_id('SERVICE_POLICYINTENTS') is not null begin drop table end SET @c = 0;end
begin if object_id('SERVICE') is not null begin drop table end SET @c = 0;end
begin if object_id('SILVERLIGHTLAYOUT') is not null begin drop table end SET @c = 0;end
begin if object_id('STRINGTOLONGMAPENTRY') is not null begin drop table end SET @c = 0;end
begin if object_id('STRINGTOSTRINGMAPENTRY') is not null begin drop table end SET @c = 0;end
begin if object_id('SUBSTITUTABLEOBJECT') is not null begin drop table end SET @c = 0;end
begin if object_id('SUBSTITUTIONBINDING') is not null begin drop table end SET @c = 0;end
begin if object_id('SUBSTITUTIONVARIABLES') is not null begin drop table end SET @c = 0;end
begin if object_id('SUBSTITUTIONVARIABLE') is not null begin drop table end SET @c = 0;end
begin if object_id('SVARRESOLVED') is not null begin drop table end SET @c = 0;end
begin if object_id('SVARSUSED') is not null begin drop table end SET @c = 0;end
begin if object_id('TAG') is not null begin drop table end SET @c = 0;end
begin if object_id('TASKRESULT_TASKDEPENDENCIES') is not null begin drop table end SET @c = 0;end
begin if object_id('TASKRESULT') is not null begin drop table end SET @c = 0;end
begin if object_id('TASK_DEPENDENCIES') is not null begin drop table end SET @c = 0;end
begin if object_id('TASK_PROCESSEDDEPENDENCIES') is not null begin drop table end SET @c = 0;end
begin if object_id('TASK') is not null begin drop table end SET @c = 0;end
begin if object_id('TCSUSER') is not null begin drop table end SET @c = 0;end
begin if object_id('UIVIEW') is not null begin drop table end SET @c = 0;end
begin if object_id('USERACTION_USERACTIONENTITYIDS') is not null begin drop table end SET @c = 0;end
begin if object_id('USERACTION') is not null begin drop table end SET @c = 0;end
begin if object_id('USERPREFPROPERTYGROUP') is not null begin drop table end SET @c = 0;end
begin if object_id('USERPREFPROPERTY') is not null begin drop table end SET @c = 0;end
begin if object_id('USERPREFPRPERTYGROP_PROPERTIES') is not null begin drop table end SET @c = 0;end
begin if object_id('USERSEARCHQUERY') is not null begin drop table end SET @c = 0;end
begin if object_id('VERSIONCLOSURE') is not null begin drop table end SET @c = 0;end
begin if object_id('WIRE') is not null begin drop table end SET @c = 0;end
begin if object_id('COMPLEXITYREQS') is not null begin drop table end SET @c = 0;end
begin if object_id('GROUP_CHILDGROUPS') is not null begin drop table end SET @c = 0;end
begin if object_id('GROUP_USERS') is not null begin drop table end SET @c = 0;end
begin if object_id('GROUP') is not null begin drop table end SET @c = 0;end
begin if object_id('HASHEDPASSWORD') is not null begin drop table end SET @c = 0;end
begin if object_id('PASSWORDHISTORY') is not null begin drop table end SET @c = 0;end
begin if object_id('PASSWORDPOLICY') is not null begin drop table end SET @c = 0;end
begin if object_id('REALM') is not null begin drop table end SET @c = 0;end
begin if object_id('USER') is not null begin drop table end SET @c = 0;end
begin if object_id('ACTIONEXECUTION') is not null begin drop table end SET @c = 0;end
begin if object_id('AGGREGATEINFO_RESETCONDITIONS') is not null begin drop table end SET @c = 0;end
begin if object_id('AGGRGTREVNTDFINITIN_METRICGRPS') is not null begin drop table end SET @c = 0;end
begin if object_id('AGGRGTRMDLS_RQIRDGGRGTRXTNSINS') is not null begin drop table end SET @c = 0;end
begin if object_id('AGGRGTRVNTDFNTNX_TMSYNCHRNZDBY') is not null begin drop table end SET @c = 0;end
begin if object_id('BASEACTION_PROVIDEDINTENTS') is not null begin drop table end SET @c = 0;end
begin if object_id('BASEACTION') is not null begin drop table end SET @c = 0;end
begin if object_id('BASEECA') is not null begin drop table end SET @c = 0;end
begin if object_id('BASEPARAMSETTING') is not null begin drop table end SET @c = 0;end
begin if object_id('BASEVAL') is not null begin drop table end SET @c = 0;end
begin if object_id('BUNDLEDGCINSTANCE') is not null begin drop table end SET @c = 0;end
begin if object_id('CHOICE') is not null begin drop table end SET @c = 0;end
begin if object_id('DEPLOYABLE') is not null begin drop table end SET @c = 0;end
begin if object_id('DEPLOYMENTFRAGMENT') is not null begin drop table end SET @c = 0;end
begin if object_id('DPLYMNTFRGMNT_PPLICTINTEMPLTES') is not null begin drop table end SET @c = 0;end
begin if object_id('ENFORCEMENTPLACEMENT') is not null begin drop table end SET @c = 0;end
begin if object_id('ENFORCEMENTPOINTPLACEMENT') is not null begin drop table end SET @c = 0;end
begin if object_id('ENFORCEMENTSECTIONPLACEMENT') is not null begin drop table end SET @c = 0;end
begin if object_id('ENFORCEMENTSTAGEPLACEMENT') is not null begin drop table end SET @c = 0;end
begin if object_id('EVENTTARGETEXTENSIN_METRICGRPS') is not null begin drop table end SET @c = 0;end
begin if object_id('EVENTTARGET_METRICGROUPS') is not null begin drop table end SET @c = 0;end
begin if object_id('EVENTTARGET_TARGETTYPES') is not null begin drop table end SET @c = 0;end
begin if object_id('EVENTTRGETEXTENSIN_TARGETTYPES') is not null begin drop table end SET @c = 0;end
begin if object_id('GOVERNEDDOMAINDEFINITION') is not null begin drop table end SET @c = 0;end
begin if object_id('GOVERNEDENTERPRISE') is not null begin drop table end SET @c = 0;end
begin if object_id('GOVERNEDOBJECTCHILDREN_VALUE') is not null begin drop table end SET @c = 0;end
begin if object_id('GOVERNEDOBJECTCHILDREN') is not null begin drop table end SET @c = 0;end
begin if object_id('GOVERNEDOBJECTPARENT') is not null begin drop table end SET @c = 0;end
begin if object_id('GOVERNEDOBJECTPROPERTYDEF') is not null begin drop table end SET @c = 0;end
begin if object_id('GOVERNEDOBJECTPROPERTY') is not null begin drop table end SET @c = 0;end
begin if object_id('GOVERNEDOBJECTREFERENCEDEF') is not null begin drop table end SET @c = 0;end
begin if object_id('GOVERNEDOBJECTREFERENCE_VALUE') is not null begin drop table end SET @c = 0;end
begin if object_id('GOVERNEDOBJECTREFERENCE') is not null begin drop table end SET @c = 0;end
begin if object_id('GOVERNEDOBJECTTYPE_SUPERTYPE') is not null begin drop table end SET @c = 0;end
begin if object_id('GOVERNEDOBJECTTYPE') is not null begin drop table end SET @c = 0;end
begin if object_id('GOVERNEDOBJECT') is not null begin drop table end SET @c = 0;end
begin if object_id('GVERNEDBJECTPARENTREFERENCEDEF') is not null begin drop table end SET @c = 0;end
begin if object_id('GVERNNCERLECTIN_PRVIDEDINTENTS') is not null begin drop table end SET @c = 0;end
begin if object_id('GVRNNCRLCTINTMPLT_PRVIDDINTNTS') is not null begin drop table end SET @c = 0;end
begin if object_id('METRICDEFINITINEXTENSIN_LIASES') is not null begin drop table end SET @c = 0;end
begin if object_id('METRICDEFINITION_ALIASES') is not null begin drop table end SET @c = 0;end
begin if object_id('METRICDEFINITION_TIMEWINDOWSET') is not null begin drop table end SET @c = 0;end
begin if object_id('METRICGROP_GOVERNEDOBJECTGROPS') is not null begin drop table end SET @c = 0;end
begin if object_id('METRICGROUP_TIMEWINDOWSET') is not null begin drop table end SET @c = 0;end
begin if object_id('METRICGRPEXTENSIN_TIMEWINDWSET') is not null begin drop table end SET @c = 0;end
begin if object_id('METRICGRP_PPLICABLECLASSIFIERS') is not null begin drop table end SET @c = 0;end
begin if object_id('MODELBLOB') is not null begin drop table end SET @c = 0;end
begin if object_id('MODELOBJECTID') is not null begin drop table end SET @c = 0;end
begin if object_id('MTRCGRPXTNSIN_PPLICBLCLSSIFIRS') is not null begin drop table end SET @c = 0;end
begin if object_id('MTRICDFINITINXTNSIN_TIMWINDWST') is not null begin drop table end SET @c = 0;end
begin if object_id('MTRICGRPEXTNSIN_GVRNDBJECTGRPS') is not null begin drop table end SET @c = 0;end
begin if object_id('PARAMETERGROUPSETTING') is not null begin drop table end SET @c = 0;end
begin if object_id('PARAMETERGROUP') is not null begin drop table end SET @c = 0;end
begin if object_id('PARAMETERPROPERTY') is not null begin drop table end SET @c = 0;end
begin if object_id('PARAMETER') is not null begin drop table end SET @c = 0;end
begin if object_id('PERSISTENCEBASE') is not null begin drop table end SET @c = 0;end
begin if object_id('PREFIXMAP') is not null begin drop table end SET @c = 0;end
begin if object_id('PROPERTYFILTER') is not null begin drop table end SET @c = 0;end
begin if object_id('PROPERTYVAL') is not null begin drop table end SET @c = 0;end
begin if object_id('QERYCONFIGRATION_TARGETMETRICS') is not null begin drop table end SET @c = 0;end
begin if object_id('QRYCNFIGRTINEXTNSIN_TRGTMTRICS') is not null begin drop table end SET @c = 0;end
begin if object_id('RELATIONPATHITEM') is not null begin drop table end SET @c = 0;end
begin if object_id('RELATIONPATH') is not null begin drop table end SET @c = 0;end
begin if object_id('RESETCNDITIONEXTENSION_TARGETS') is not null begin drop table end SET @c = 0;end
begin if object_id('RESOURCEINSTANCEMAP') is not null begin drop table end SET @c = 0;end
begin if object_id('RESOURCETEMPLATEASSOCIATION') is not null begin drop table end SET @c = 0;end
begin if object_id('RSRCETEMPLTESSCITIN_LLWEDTYPES') is not null begin drop table end SET @c = 0;end
begin if object_id('RSRCTMPLTSSCITIN_RFPRPERTYNMES') is not null begin drop table end SET @c = 0;end
begin if object_id('RULEACTION') is not null begin drop table end SET @c = 0;end
begin if object_id('RULETEMPLATEREF') is not null begin drop table end SET @c = 0;end
begin if object_id('RULE_PROVIDEDINTENTS') is not null begin drop table end SET @c = 0;end
begin if object_id('RULE_TAGS') is not null begin drop table end SET @c = 0;end
begin if object_id('RULE') is not null begin drop table end SET @c = 0;end
begin if object_id('SINGLEVAL_REFPROPERTYNAMES') is not null begin drop table end SET @c = 0;end
begin if object_id('SINGLPRMSETTING_REFPRPERTYNMES') is not null begin drop table end SET @c = 0;end
begin if object_id('SUBSTITUTIONVARIABLEREF') is not null begin drop table end SET @c = 0;end
begin if object_id('TARGETDEFINITION_TYPES') is not null begin drop table end SET @c = 0;end
begin if object_id('TARGETOBJECTGROUPSELECTOR') is not null begin drop table end SET @c = 0;end
begin if object_id('TEMPLATECATEGORY_SUBCATEGORIES') is not null begin drop table end SET @c = 0;end
begin if object_id('TEMPLATECATEGORY') is not null begin drop table end SET @c = 0;end
begin if object_id('TEMPLATE') is not null begin drop table end SET @c = 0;end
begin if object_id('TIMEWINDOWSET_WINDOW') is not null begin drop table end SET @c = 0;end
begin if object_id('TIMEWINDWSET_GVERNEDOBJECTGRPS') is not null begin drop table end SET @c = 0;end
begin if object_id('TIMWINDWEXTNSIN_GVRNDBJECTGRPS') is not null begin drop table end SET @c = 0;end
begin if object_id('UNBOUNDEDPARAMSETTING_VALUES') is not null begin drop table end SET @c = 0;end
begin if object_id('UNBOUNDEDVAL_VALUES') is not null begin drop table end SET @c = 0;end
begin if object_id('VERSIONEDOBJECT') is not null begin drop table end SET @c = 0;end
begin if object_id('WNDWHISTRYDFINITIN_RSTCNDITINS') is not null begin drop table end SET @c = 0;end
begin if object_id('ACTIVESTARTTIMES') is not null begin drop table end SET @c = 0;end
begin if object_id('BASEEVENTFORMAT_CLASSIFIERS') is not null begin drop table end SET @c = 0;end
begin if object_id('BASEEVENTFORMAT_PAYLOADIDS') is not null begin drop table end SET @c = 0;end
begin if object_id('BASEEVENTFORMAT') is not null begin drop table end SET @c = 0;end
begin if object_id('CLASSIFIERBEFMAP') is not null begin drop table end SET @c = 0;end
begin if object_id('CLASSIFIERGROUPS') is not null begin drop table end SET @c = 0;end
begin if object_id('CLASSIFIER') is not null begin drop table end SET @c = 0;end
begin if object_id('CLQUERYMODEL') is not null begin drop table end SET @c = 0;end
begin if object_id('ECOMPID') is not null begin drop table end SET @c = 0;end
begin if object_id('LGGINGPOLICYMESSAGE_PROPERTIES') is not null begin drop table end SET @c = 0;end
begin if object_id('LOGGINGPOLICYMESSAGE') is not null begin drop table end SET @c = 0;end
begin if object_id('LOGGINGPOLICYMODEL_MESSAGES') is not null begin drop table end SET @c = 0;end
begin if object_id('LOGGINGPOLICYPROPERTY') is not null begin drop table end SET @c = 0;end
begin if object_id('LOGSERVICE') is not null begin drop table end SET @c = 0;end
begin if object_id('OTHERSITUATION_ANY') is not null begin drop table end SET @c = 0;end
begin if object_id('PAYLOADDATA') is not null begin drop table end SET @c = 0;end
begin if object_id('PAYLOAD') is not null begin drop table end SET @c = 0;end
begin if object_id('REPORTINGCOMPONENTID') is not null begin drop table end SET @c = 0;end
begin if object_id('SITUATIONTYPE') is not null begin drop table end SET @c = 0;end
begin if object_id('STATSCLASSIFIERS') is not null begin drop table end SET @c = 0;end
begin if object_id('APPLICATIONARTIFACT') is not null begin drop table end SET @c = 0;end
begin if object_id('APPLICATIONARTIFACT_FEATURES') is not null begin drop table end SET @c = 0;end
begin if object_id('APPLICTINRTIFCT_RESRCETEMPLTES') is not null begin drop table end SET @c = 0;end
end
页: [1]
查看完整版本: How to forcely drop tables in SQL Server 2008