Microsoft SQL Server
001. インデックス・デフラグ
-- インデックス指定 DBCC INDEXDEFRAG (TEMPDB, "dbo.TABLE01", "TABLE01~001"); -- テーブル指定 DBCC DBREINDEX ("TEMPDB.dbo.TABLE01"," "); |
002. コマンドラインから SQL を実行
▽Windows 認証の場合
isql -S 192.168.0.1 -E -d TEMPDB -i test.sql |
▽SQL Server 認証の場合
isql -S 192.168.0.1 -U user_name -P password -d TEMPDB -i test.sql |
003. 固定長データファイルをロード
bcp ユーティリティを使う > サンプルファイル

004. 権限照会/権限追加/権限拒否/権限取消
-- 権限照会 sp_helprotect; -- 権限追加 grant select on TABLE01 to user_name; grant insert on TABLE01 to user_name; grant update on TABLE01 to user_name; grant delete on TABLE01 to user_name; -- 権限拒否 deny update on TABLE01 to user_name; -- 権限取消 revoke update on TABLE01 to user_name; |
005. インデックス照会/追加/削除
-- インデックス照会 sp_helpindex "dbo.TABLE01"; sp_statistics "TABLE01"; -- インデックス追加/削除 CREATE INDEX [TABLE01~001] ON [dbo].[TABLE01] ([COL01],[COL02],[COL03]); DROP INDEX [dbo].[TABLE01].[TABLE01~001]; |
006. 領域使用状況レポート
select getdate(); go; select count(*) from TABLE01; go; dbcc updateusage (TEMPDB, TABLE01) with count_rows; go; exec sp_spaceused "TEMPDB.dbo.TABLE01"; go; |
007. DTS で 10秒待つ
'********************************************************************** ' Visual Basic ActiveX スクリプト '********************************************************************** Function Main() Main = DTSTaskExecResult_Success Set WshShell = CreateObject("WScript.Shell") x = WshShell.Run("ping -n 10 localhost", 0, True) End Function |