新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
刪除數(shù)據(jù)庫(kù)所有存儲(chǔ)過(guò)程的SQL語(yǔ)句
下面為您介紹能夠一次性刪除數(shù)據(jù)庫(kù)所有存儲(chǔ)過(guò)程的SQL語(yǔ)句,供您參考,如果您對(duì)相關(guān)的SQL語(yǔ)句感興趣,不妨一看,希望能夠?qū)δ兴鶈⒌稀?/p>

--/第1步**********刪除所有表的外鍵約束*************************/
[[15062]][[15063]]代碼
DECLARE
c1
cursor
for
select
'
alter table [
'
+
object_name
(parent_obj)
+
'
] drop constraint [
'
+
name
+
'
];
'
from
sysobjects
where
xtype
=
'
F
'
open
c1
declare
@c1
varchar
(
8000
)
fetch
next
from
c1
into
@c1
while
(
@@fetch_status
=
0
)
begin
exec
(
@c1
)
fetch
next
from
c1
into
@c1
end
close
c1
deallocate
c1
--/第2步**********刪除所有表*************************/
use
數(shù)據(jù)庫(kù)
declare
@tname
varchar
(
8000
)
set
@tname
=
''
select
@tname
=
@tname
+
Name
+
'
,
'
from
sysobjects
where
xtype
=
'
U
'
select
@tname
=
'
drop table
'
+
left
(
@tname
,
len
(
@tname
)
-
1
)
exec
(
@tname
)
--/第2步**********刪除所有存儲(chǔ)過(guò)程*************************/
use
數(shù)據(jù)庫(kù)
declare
@tname
varchar
(
8000
)
set
@tname
=
''
select
@tname
=
@tname
+
Name
+
'
,
'
from
sysobjects
where
xtype
=
'
P
'
select
@tname
=
'
drop Procedure
'
+
left
(
@tname
,
len
(
@tname
)
-
1
)
exec
(
@tname
)
網(wǎng)站欄目:刪除數(shù)據(jù)庫(kù)所有存儲(chǔ)過(guò)程的SQL語(yǔ)句
鏈接分享:http://fisionsoft.com.cn/article/codsijp.html


咨詢
建站咨詢
