This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE [msdb] | |
GO | |
/****** Object: Job [DB作成] Script Date: 01/14/2016 14:00:18 ******/ | |
BEGIN TRANSACTION | |
DECLARE @ReturnCode INT | |
SELECT @ReturnCode = 0 | |
/****** Object: JobCategory [Database Maintenance] Script Date: 01/14/2016 14:00:18 ******/ | |
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'Database Maintenance' AND category_class=1) | |
BEGIN |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Back up the full master database. | |
USE master | |
BACKUP DATABASE master TO DISK='C:\DBBACKUP\NEW\master_db.bak' WITH INIT | |
-------------------------------------------------------------------------------------------- | |
-- Back up the full model database. | |
USE model | |
BACKUP DATABASE model TO DISK='C:\DBBACKUP\NEW\model_db.bak' WITH INIT | |
BACKUP LOG model TO DISK='C:\DBBACKUP\NEW\model_log.bak' WITH INIT | |
-------------------------------------------------------------------------------------------- | |
-- Back up the full msdb database. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--SQLServerでDBファイルのサイズ等を出力する為のSQL | |
USE [DB名] | |
SELECT file_id, name, type_desc, physical_name, size, max_size | |
FROM sys.database_files ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#powershellから管理者権限でコマンド実行する方法 | |
powershell.exe -Command "Start-Process -Verb runas calc" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#参考URL | |
http://qiita.com/kikuchi/items/59f219eae2a172880ba6 | |
#起動時に『-ExecutionPolicy』オプション、スクリプトパスを指定すると、そのプロセス限定で起動可能 | |
powershell -ExecutionPolicy RemoteSigned -File .\hello.ps1 | |
#以下、ログオンスクリプトにpowershellスクリプトを指定可能 | |
http://blogs.technet.com/b/stanabe/archive/2010/11/09/win7-logon-script-with-powershell.aspx | |
http://tech.guitarrapc.com/entry/2015/07/24/084117 | |
http://pcmemorin.blog.fc2.com/blog-entry-1127.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#コマンドプロンプトからSQL ServerへSQLスクリプトを実行 | |
参考URL | |
http://plus-sys.jugem.jp/?eid=193 | |
REM 使用例(バッチ) | |
sqlcmd -S インスタンス名(サーバー名) -U ユーザー名 -P パスワード -d データベース名 -i c:¥test.sql -o C:\log.txt | |
REM 使用例(インタプリタ) | |
sqlcmd -S インスタンス名(サーバー名) -U ユーザー名 -P パスワード -d データベース名 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
参考URL | |
--https://msdn.microsoft.com/ja-jp/library/ms186976(v=sql.120).aspx | |
--https://msdn.microsoft.com/ja-jp/library/ms188745(v=sql.120).aspx | |
USE msdb ; | |
GO | |
--有効化(enable=1) | |
EXEC dbo.sp_update_job | |
@job_name = N'ジョブ名', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#GAEA_TEST ユーザーマスタ(MA_KYT_User)検索スクリプト | |
#↓ | |
#GAEA_TEST 代替品帳票コントロール・リフレクションマスタ(代替品関連)検索スクリプト | |
[string]$conStr | |
[string]$query | |
#[switch]$isSQLServer | |
$conStr = "Data Source=TEGAEADB01;Initial Catalog=GAEA_TEST;UID=sa;PWD=blsBLSbls" | |
#$query = "select * from MA_KYT_USER" |