您好,登錄后才能下訂單哦!
MSSQL 中怎么刪除數(shù)據(jù)庫(kù)里某個(gè)用戶所有表里的數(shù)據(jù),相信很多沒有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。
-->Title:刪除數(shù)據(jù)庫(kù)里某個(gè)用戶所有表里的數(shù)據(jù) -->Author:wufeng4552 -->Date :2009-09-21 15:08:41 --
方法1
代碼如下:
declare @uname varchar(20) declare cuser cursor for select so.name from sysobjects so,sysusers su where so.uid=su.uid and su.name='Stone' and so.xtype='U' open cuser fetch next from cuser into @uname while(@@fetch_status=0) begin exec('truncate table [Stone].['+@uname+']') fetch next from cuser end close cuser deallocate cuser
--方法2
代碼如下:
exec sp_msforeachtable @command1="truncate table ? ;",@whereand='and schema_id = (select schema_id from sys.schemas where [name] =''Stone'')'
看完上述內(nèi)容,你們掌握MSSQL 中怎么刪除數(shù)據(jù)庫(kù)里某個(gè)用戶所有表里的數(shù)據(jù)的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。