MSBI (SSIS/SSRS/SSAS) Online Training

Friday, January 30, 2009

My Favorite XMLA-Script2 Of This Month:-

b).Measure Process with Partition- Measure Process Script:-


' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.IO

Public Class ScriptMain
Public Sub Main()

Dim temp1 As String
Dim temp2 As String

Dts.Variables.Item("strProcessScript1").Value = _
""
temp1 = " "
temp2 = " " + _
"-1" + _
"" + Dts.Variables.Item("strErrorLogLocation").Value.ToString + "Log.Log" + "" + _
"ReportAndContinue" + _
"ReportAndContinue" + _
"
"

Dts.Variables.Item("strProcessScript2").Value = _
"
"

Dts.Variables.Item("strMeasureProcess").Value = _
Dts.Variables.Item("strProcessScript1").Value.ToString + temp2 + temp1 + _
Dts.Variables("strProcessScript").Value.ToString + _
Dts.Variables("strProcessScript_Add").Value.ToString + _
" " + _
" " + _
Dts.Variables("strProcessScript_Bindings").Value.ToString + _
"
" + _
Dts.Variables.Item("strProcessScript2").Value.ToString

'MsgBox(Dts.Variables.Item("strMeasureProcess").Value)

Dim temp3 As String
temp3 = Dts.Variables("strProcessScript_Add").Value.ToString + _
Dts.Variables("strProcessScript_Bindings").Value.ToString
'MsgBox(temp3)

Dim f As File
f.WriteAllText("C:\test.txt", Dts.Variables("strMeasureProcess").Value.ToString())

Dts.TaskResult = Dts.Results.Success
End Sub
'Dts.Variables("strProcessScript").Value.ToString + _

End Class


*************************

Here
'ProcessScript =='Add' Type
Dts.Variables.Item("strProcessScript_Add").Value
'ProcessScript ==Bindings Type Dts.Variables.Item("strProcessScript_Bindings").Value
'ProcessScript ==Index Type Dts.Variables.Item("strProcessScript_Index").Value
Else Part

Dts.Variables.Item("strProcessScript").Value

Values are coming from for Eachloop container like the given below script:
This is for all the Measures along with Partition and Index Script:

' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime

Public Class ScriptMain


Public Sub Main()

'ProcessScript =='Add' Type

If ((Dts.Variables.Item("ProcessType").Value.ToString) = "ProcessAdd") Then


Dts.Variables.Item("strProcessScript_Add").Value = Dts.Variables.Item("strProcessScript_Add").Value.ToString() + _
" " + _
" " + _
" " + Dts.Variables.Item("strDatabasename").Value.ToString + "" + _
" " + Dts.Variables.Item("strCubename").Value.ToString + "" + _
" " + Dts.Variables.Item("strMeasurename").Value.ToString + "" + _
" " + Dts.Variables.Item("strPartitionname").Value.ToString + "" + _
"
" + _
" " + Dts.Variables.Item("ProcessType").Value.ToString + "" + _
"UseExisting" + _
"
"

'ProcessScript ==Bindings Type

Dts.Variables.Item("strProcessScript_Bindings").Value = Dts.Variables.Item("strProcessScript_Bindings").Value.ToString() + _
" " + _
" " + Dts.Variables.Item("strDatabasename").Value.ToString + "" + _
" " + Dts.Variables.Item("strCubename").Value.ToString + " " + _
" " + Dts.Variables.Item("strMeasurename").Value.ToString + " " + _
" " + Dts.Variables.Item("strPartitionname").Value.ToString + " " + _
" " xmlns:xsi=" + """" + "http://www.w3.org/2001/XMLSchema-instance" + """" + _
" xsi:type=" + """" + "QueryBinding" + """" + ">" + _
" " + Dts.Variables.Item("strDataSourcename").Value.ToString + "" + _
" " + Dts.Variables.Item("strQueryDefinition").Value.ToString + "" + _
" " + _
"
"


'ProcessScript ==Index Type
Dts.Variables.Item("strProcessScript_Index").Value = Dts.Variables.Item("strProcessScript_Index").Value.ToString() + _
" " + _
" " + _
" " + Dts.Variables.Item("strDatabasename").Value.ToString + "" + _
" " + Dts.Variables.Item("strCubename").Value.ToString + "" + _
" " + Dts.Variables.Item("strMeasurename").Value.ToString + "" + _
" " + Dts.Variables.Item("strPartitionname").Value.ToString + "" + _
"
" + _
" ProcessIndexes" + _
"UseExisting" + _
"
"

Else

Dts.Variables.Item("strProcessScript").Value = Dts.Variables.Item("strProcessScript").Value.ToString() + _
" " + _
" " + _
" " + Dts.Variables.Item("strDatabasename").Value.ToString + "" + _
" " + Dts.Variables.Item("strCubename").Value.ToString + "" + _
" " + Dts.Variables.Item("strMeasurename").Value.ToString + "" + _
"
" + _
" " + Dts.Variables.Item("ProcessType").Value.ToString + "" + _
"UseExisting" + _
"
"

Dts.TaskResult = Dts.Results.Success
End If

End Sub

End Class



d).Partition –Measure Process –Index Script:-

' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime

Public Class ScriptMain
Public Sub Main()

Dim temp1 As String
Dim temp2 As String

Dts.Variables.Item("strProcessScript1").Value = _
""
temp1 = " "
temp2 = " " + _
"-1" + _
"" + Dts.Variables.Item("strErrorLogLocation").Value.ToString + "Log.Log" + "" + _
"ReportAndContinue" + _
"ReportAndContinue" + _
"
"

Dts.Variables.Item("strProcessScript2").Value = _
"
" + _
"
"

Dts.Variables.Item("strMeasureProcess_Add").Value = _
Dts.Variables.Item("strProcessScript1").Value.ToString + temp2 + temp1 + _
Dts.Variables("strProcessScript_Index").Value.ToString + _
Dts.Variables.Item("strProcessScript2").Value.ToString

'MsgBox(Dts.Variables.Item("strMeasureProcess_Add").Value)

Dts.TaskResult = Dts.Results.Success
End Sub

End Class

No comments: