具體解決方案如下:解決方案1:SELECT"droptable"+name+";"FROMsys.tables解決方案2:--刪除外來鍵約束DECLAREc1cursorforselect"altertable["+object_name(parent_obj)+"]dropconstraint["+name+"];"fromsysobjectswherextype="F"openc1declare@c1varchar(8000)fetchnextfromc1into@c1while(@@fetch_status=0)beginexec(@c1)fetchnextfromc1into@c1endclosec1deallocatec1--刪除表DECLAREc2cursorforselect"droptable["+name+"];"fromsysobjectswherextype="u"openc2declare@c2varchar(8000)fetchnextfromc2into@c2while(@@fetch_status=0)beginexec(@c2)fetchnextfromc2into@c2endclosec2deallocatec2SELECT"droptable"+name+";"FROMsys.tables解決方案2:--刪除外來鍵約束DECLAREc1cursorforselect"altertable["+object_name(parent_obj)+"]dropconstraint["+name+"];"fromsysobjectswherextype="F"openc1declare@c1varchar(8000)fetchnextfromc1into@c1while(@@fetch_status=0)beginexec(@c1)fetchnextfromc1into@c1endclosec1deallocatec1--刪除表DECLAREc2cursorforselect"droptable["+name+"];"fromsysobjectswherextype="u"openc2declare@c2varchar(8000)fetchnextfromc2into@c2while(@@fetch_status=0)beginexec(@c2)fetchnextfromc2into@c2endclosec2deallocatec2SELECT"droptable"+name+";"FROMsys.tables
具體解決方案如下:解決方案1:SELECT"droptable"+name+";"FROMsys.tables解決方案2:--刪除外來鍵約束DECLAREc1cursorforselect"altertable["+object_name(parent_obj)+"]dropconstraint["+name+"];"fromsysobjectswherextype="F"openc1declare@c1varchar(8000)fetchnextfromc1into@c1while(@@fetch_status=0)beginexec(@c1)fetchnextfromc1into@c1endclosec1deallocatec1--刪除表DECLAREc2cursorforselect"droptable["+name+"];"fromsysobjectswherextype="u"openc2declare@c2varchar(8000)fetchnextfromc2into@c2while(@@fetch_status=0)beginexec(@c2)fetchnextfromc2into@c2endclosec2deallocatec2SELECT"droptable"+name+";"FROMsys.tables解決方案2:--刪除外來鍵約束DECLAREc1cursorforselect"altertable["+object_name(parent_obj)+"]dropconstraint["+name+"];"fromsysobjectswherextype="F"openc1declare@c1varchar(8000)fetchnextfromc1into@c1while(@@fetch_status=0)beginexec(@c1)fetchnextfromc1into@c1endclosec1deallocatec1--刪除表DECLAREc2cursorforselect"droptable["+name+"];"fromsysobjectswherextype="u"openc2declare@c2varchar(8000)fetchnextfromc2into@c2while(@@fetch_status=0)beginexec(@c2)fetchnextfromc2into@c2endclosec2deallocatec2SELECT"droptable"+name+";"FROMsys.tables