2

When traversing a Dacpac via C# code, I am able to figure out which columns are referenced in a computed column (GetReferenced(Microsoft.SqlServer.Dac.Model.Column.ExpressionDependencies)), and what the expression for the column is (Microsoft.SqlServer.Dac.Model.Column.Expression property). What I cannot find, is the datatype of the computed column.

Besides that, I also cannot find a way to retrieve the columns of a FileTable table (although this is a static set of columns).

Search engines won't bring me far; there aren't that many resource to be found on this topic.

user353gre3
  • 2,747
  • 4
  • 24
  • 27

1 Answers1

2

I have blogged here how to get the data type of columns:

http://sqlserverfunctions.wordpress.com/category/dacfx-2/

I haven't tried it on computed columns.

To get columns for a file table, follow the blog but replace Table.Columns ModelRelationshipClass with FileTable.Columns ModelRelationshipClass.

Ed

Ed Elliott
  • 6,666
  • 17
  • 32
  • Hi Ed, I already found your blog, and found it very usefull as a guidance for my first steps. The issue described in this question, is not answered by your blog, however. Also if I use your tool "dacpac explorer", I cannot get the type of computed columns. It displays the Expression correctly, but for Type it points to the referenced column(s). The referenced column datatypes are not always equal to the datatype of the computed column. – Juul van Iersel Dec 03 '14 at 00:18
  • Thanks fot the tip regarding the FileTable, accidentally used Table instead of FileTable. – Juul van Iersel Dec 03 '14 at 00:37
  • Cool, it looks like the datatype of a computed column doesn't actually exist in sql - if you look in the model.xml there is no type specifier. I wasn't sure if it was a bug with the DacFx api but if you find a table in ssms and script it out - that doesn't have it either so sql must evaluate it when it compiles it at run time. – Ed Elliott Dec 03 '14 at 07:21
  • @EdElliott - Ed, sorry to make a request like this but since you are an expert with SSDT and Dac api, by any chance do you know a solution to this http://stackoverflow.com/questions/44058693/how-to-get-type-of-a-column-using-dacfx-api question? – haku May 18 '17 at 22:29
  • No problem but everyone has to sleep :) Like Steven said use the dac extensions it makes it so much simpler to use the dacfx for exploring dacpac's - this answer was from before that existed so I'll update it to include details – Ed Elliott May 19 '17 at 05:01