Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting the DataSource Property from DataTable in DSV

Status
Not open for further replies.

capitanosol

Programmer
Oct 26, 2012
4
0
0
CA
Hi, this is my first time here....

I have a written a small function in a SSIS Script task objet in order to extract some infomation about Cube that are on my server...
I am almost done but I cannot extract the datasource from each table in a DSV starting from the cude. Some table in the same DSV comes from different DataSources.

Dim oServer As Microsoft.AnalysisServices.Server
oServer = New Microsoft.AnalysisServices.Server()
oServer.Connect("***")

For Each oDB As Microsoft.AnalysisServices.Database In oServer.Databases
For Each oCube As Microsoft.AnalysisServices.Cube In oDB.Cubes
For Each oTBL As DataTable In oCube.DataSourceView.Schema.Tables.
Sortie0Buffer.AddRow()
Sortie0Buffer.SSASDatabaseName = oDB.Name
Sortie0Buffer.CubeName = oCube.Name
Sortie0Buffer.TableName = oTBL.TableName
Sortie0Buffer.TableSource = oTBL.DataSet.DataSetName
Sortie0Buffer.DataSource = ???
Sortie0Buffer.TableType = oTBL.ExtendedProperties("TableType")
Next
Next
Next
oServer.Disconnect()

Can someone help me ?
 
I recommend you think outside the box, or cube in this case.....

You can have separate queries and join them via UNION or join the result sets using unix shell or powershell.

Just an idea. HTH.

====================================
The trouble with doing something right the first time is that nobody appreciates how difficult it was - Steven Wright
 
Thanks for your response.

Finally I had my solution. Not sure it's very clean but it work's fine for me. If someone have cleaner code it would be nice for the community.

Here is what i did :

Dim oServer As Microsoft.AnalysisServices.Server
Dim DataSourceName As String
Dim cs As String
Dim Str1 As String

oServer = New Microsoft.AnalysisServices.Server()
oServer.Connect("****MyServerName****")

For Each oDB As Microsoft.AnalysisServices.Database In oServer.Databases
For Each oCube As Microsoft.AnalysisServices.Cube In oDB.Cubes
For Each oTBL As DataTable In oCube.DataSourceView.Schema.Tables
Sortie0Buffer.AddRow()
Sortie0Buffer.DatabaseName = oDB.Name
Sortie0Buffer.CubeName = oCube.Name
Sortie0Buffer.TableName = oTBL.TableName
Sortie0Buffer.TableSource = oTBL.DataSet.DataSetName

If Not String.IsNullOrEmpty(oTBL.ExtendedProperties("DataSourceID")) Then
DataSourceName = oTBL.ExtendedProperties("DataSourceID")
Else
DataSourceName = oCube.DataSourceView.DataSource.Name
End If

Sortie0Buffer.DataSource = DataSourceName

Sortie0Buffer.QueryDefinition = oTBL.ExtendedProperties("QueryDefinition")

If Not String.IsNullOrEmpty(oTBL.ExtendedProperties("QueryDefinition")) Then
Sortie0Buffer.TableType = "NamedQuery"
Else
Sortie0Buffer.TableType = oTBL.ExtendedProperties("TableType")
End If

cs = oDB.DataSources.FindByName(DataSourceName).ConnectionString

Str1 = cs.Substring(cs.IndexOf("Data Source=") + 12, 20)
Sortie0Buffer.DataSourceServer = Str1.Substring(0, Str1.IndexOf(";"))
Next
Next
Next
oServer.Disconnect()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top