清空資料表
TRUNCATE TABLE
不重複
DISTINCT
一次刪除所有表SQL語句如下
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)
刪除所有存儲過程的sql語句 用到游標
declare @procName varchar(500)
declare cur cursor
for select [name] from sys.objects where type = 'p'
open cur
fetch next from cur into @procName
while @@fetch_status = 0
begin
if @procName <> 'DeleteAllProcedures'
exec('drop procedure ' + @procName)
fetch next from cur into @procName
end
close cur
deallocate cur
-----------------------------------------------------------------------------------------
資料轉載至[影子_百度空間]
http://hi.baidu.com/bj1686/item/c7a1460749359ddcdde5b098
-----------------------------------------------------------------------------------------
查詢 SQL Server 上面全部資料庫的檔案大小
可以快速查詢全部的資料庫,其包含了資料檔案、交易記錄檔案的大小。
適用版本:
SQL Server 2005、2008、2008 R2
SELECT DB_NAME(database_id) N'資料庫', physical_name N'實體檔案', type_desc N'檔案類型', state_desc N'檔案狀態', size*8.0/1024/1024 N'檔案大小(GB)'
FROM sys.master_files
-----------------------------------------------------------------------------------------
資料轉載至[德瑞克:SQL Server 學習筆記]
http://sharedderrick.blogspot.tw/2010/11/sql-server.html
-----------------------------------------------------------------------------------------