Sql-server – Visual Studio DAC with Schemabound View containing hierarchyid::GetRoot() – Two part name needed

sql serversql-clrvisual studio

In Visual Studio, when trying to create a DAC which has a schemabound view which contains hierarchyid::GetRoot() this error is generated and the project does not build. However, the t-sql is ok as if I create the view directly in the database it works ok.

Is there a two part name for hierarchyid to solve this?

In a DAC project is VS:

CREATE VIEW [dbo].[View1]
with schemabinding
AS SELECT hierarchyid::GetRoot() as t

Gives:

Error 93 SQL70561: Cannot schema bind view '[dbo].[View1]' because name 'hierarchyid' is invalid for schema binding. Names must be in two-part format and an object cannot reference itself.

Best Answer

The answer is to add sys. in front of the hierarchyId:

sys.hierarchyid::GetRoot()