8. SQL Server BI ~ 3つの柱
必要最小限のSQL文の知識と、若干のコーディング力が求められる
【データの準備】SSIS:SQL Server Integration Service
データ移入作業の可視化と整形
・外部フゔル、データベースからの取り込み
・データ変換
【データの分析】SSAS:SQL Server Analysis Service
多次元データベースによる分析
【データの可視化】SSRS:SQL Server Reporting Service
資料作成の単純化
• レポートテンプレートの作成、表示、印刷
• パラメタ化による動的なレポートの生成
• レポートの共有
• Report Builder での容易な作成 8
9. SQL Server 2008 のBI
SQL Server SharePoint
SSRS Report
Builder
SQL Business Intelligence
SSIS
Development Studio
DB
SSAS
Business Intelligence
Development Studio
外部データソース 9
10. SQL Server 2008 R2 でBIはこう変わる
従来からの機能はそのままに、より使いやすく
SQL Server SharePoint
PowerPivot for
SharePoint Reports
BIという観点では影
が薄れるがDWH構築
には継続的に必須
SSRS
EXCEL Services
発
行 編 発
レ
集 ポ 行
SQL
SSIS
ー
DB ト
作
成
Report
SSAS Builder
PowerPivot for EXCEL
外部データソース 10
12. デモ環境
Windows Server 2008 R2 x64
・Active Directory
・SQL Server 2008 R2 EE x64
・ンスタンス機能
SQL01 〓データベースエンジンサービス(MSSQLSERVER)
・共有機能
〓Business Intelligence Development Studio
〓Integration Service
Windows Server 2008 R2 x64(ドメンに参加済み)
・SharePoint Server 2010 Beta
・SQL Server 2008 R2 EE x64
SP01 ・ンスタンス機能
〓データベースエンジンサービス(GEMINIBI)
・共有機能
〓Analysis Service integrated to SharePoint
Windows 7(※ドメンに参加済)
・EXCEL 2010 Beta
CLI01 ・SQL Server 2008 R2 PowerPivot for Excel 2010 - CTP 11 月版
・SQL Server 2008 R2 CTP 11 月版レポート ビルダー 3.0
・2007 Office system ドラバ: データ接続コンポーネント
SQL Azure
12
13. デモ環境に必要なもの
• Windows Server 2008 または 2008 R2
■評価版ダウンロード
[2008](最大240日)
http://www.microsoft.com/japan/windowsserver2008/trial-software.mspx
※評価機関延長方法 http://support.microsoft.com/kb/948472
[2008R2](最大180日)
http://technet.microsoft.com/ja-jp/evalcenter/dd459137.aspx
• SQL Server 2008 R2 CTP 11月版
http://www.microsoft.com/japan/sqlserver/2008/r2/prodinfo/
downloads.mspx
• SharePoint Server Enterprise 2010 Beta版
「SharePoint サーバー 2010」で検索してください
• Office 2010 Beta 版
http://technet.microsoft.com/ja-jp/evalcenter/ee390818.aspx
• SQL Server 2008 R2 PowerPivot for Excel 2010 - CTP 11 月版
x64 http://go.microsoft.com/fwlink/?LinkID=168584&clcid=0x411
x86 http://go.microsoft.com/fwlink/?LinkID=168583&clcid=0x411
• SQL Server 2008 R2 CTP 11 月版レポート ビルダー 3.0
「 SQL Server 2008 R2 CTP 11 月版レポート ビルダー 3.0」で検索してください
• OLEDBドライバ(32ビット)
2007 Office system ドライバ: データ接続コンポーネント
※検索してください! 13
14. はじめの一歩
使用するツール
• SQL Server Business Intelligence Development Studio
• SQL Server Management Studio
はじめにやること
• SQL Server Management Studio を起動
• SQL Server Business Intelligence Development Studioを起動
Access/EXCELから読み込む場合には
• SQL Server Business Intelligence Development Studioの[プロジェクト]-
[プロパテゖ]-[デバッグ]で Run64bitRuntime = False に設定
※OLEDBドラバがx64に対応していないため
14
56. (参考)ベントログを取得するスクリプト例
strComputer = “.”
Set objService = GetObject(“winmgmts:¥¥“ & strComputer & “¥root¥cimv2”)
Set objEvtSet = objService.ExecQuery _
("Select * From Win32_NTLogEvent Where Logfile='System'")
For Each e In objEvtSet
wscript.echo e.ComputerName & "," & e.EventCode
Next
56
57. Logfile 属性について
使用可能なLogfile属性は、以下のコマンドで調査できる
C:¥> wmic nteventlog list brief
FileSize LogfileName Name
NumberOfRecords
6361088 Application C:¥ ¥Logs¥Application.evtx 8022
69632 HardwareEvents C:¥ ¥Logs¥HardwareEvents.evtx 0
69632 Internet Explorer C:¥ ¥Logs¥Internet Explorer.evtx 0
69632 Key Management Service C:¥ ¥Logs¥Key Management Service.evtx 0
69632 Media Center C:¥ ¥Logs¥Media Center.evtx 0
1052672 OAlerts C:¥ ¥Logs¥OAlerts.evtx 254
69632 ODiag C:¥ ¥Logs¥ODiag.evtx 0
69632 Operations Manager C:¥ ¥Logs¥Operations Manager.evtx 120
69632 OSession C:¥ ¥Logs¥OSession.evtx 4
30740480 Security C:¥ ¥Logs¥Security.evtx 40359
8458240 System C:¥ ¥Logs¥System.evtx 20623
1118208 Windows PowerShell C:¥ ¥Logs¥Windows PowerShell.evtx
57
79. 処理6:Insert 文を生成
SQL文を生成するにあたり、各値をSQL Serverに取り込み可能な形式に整形する
User::Category
User::User 変数の値がNullかどう
かをチェックしてから
取り出す
Dim strCategory As String = ""
If Not IsDBNull(Dts.Variables("User::Category").Value) Then
strCategory = Dts.Variables("User::Category").Value.ToString
End If
Messageにはシングルクオーテーションが
含まれているので置き換え
Script
Dim strMessage As String = ""
If Not IsDBNull(Dts.Variables("User::Message").Value) Then
タ strMessage = Dts.Variables("User::Message").Value.ToString
ス strMessage = Replace(strMessage, "'", "-")
ク End If
79
次のページに続く
80. DateTime列に取り込めるように整形
Dim strTimeGenerated As String = "19000101 00:00:00"
If Not IsDBNull(Dts.Variables("User::TimeGenerated").Value) Then
strTimeGenerated = Dts.Variables("User::TimeGenerated").Value.ToString
strTimeGenerated = Mid(strTimeGenerated, 1, 8) & " " & _
Mid(strTimeGenerated, 9, 2) & ":" & _
Mid(strTimeGenerated, 11, 2) & ":" & _
Script
Mid(strTimeGenerated, 13, 2)
End If
SQL文を生成
タ
ス Dim strSQL As String = "INSERT INTO [EventLog].[dbo].[EventLogData_" &
ク
strLogfile & "] ([Category]" & _
",[CategoryString]" & _
",[ComputerName]" & _
" VALUES('" & strCategory & "'," & _
"'" & strCategoryString & "'," & _
"'" & strComputerName & "'," & _
Dts.Variables("User::InsertSQL").Value = strSQL
User::InsertSQL
80
81. 処理7:Insert Into を実行
User::InsertSQL
SQLStatement
User::InsertSQL
Value
INSERT INTO
[EventLog].[dbo].[EventLogData_Application]
dbo.Eventlog
([Category],[CategoryString],[ComputerName],[D
接
ata],[EventCode],[EventIdentifier],[EventType],[In
SQL
続
sertionStrings],[LogFile],[Message],[RecordNumb マ
タ ') er],[SourceName],[TimeGenerated],[TimeWritten] ネ
ス ,[Type],[User]) VALUES('0','','TF-SQL01- ー
ク 01.t6303.contoso.co.jp','','12290','1073819650','3' ジ
ャ
,'System.String[]','Application','Package "Package"
has been
cancelled.',3205,'SQLISPackage100','20090923
03:23:31','20090923 03:23:31','情報
','T6303¥administrator')
81
104. 6.リレーションシップの作成
ゕプリケーションログ
ID
ベントタプ
Type 時間軸
Type 日時2
ServerName 日時
日時2
システムログ 年
ComputerList
ID
月
ComputerName
Type 日
日時2
ServerName 時
分
セキュリテゖログ
ID
Type
日時2
ServerName
104