Microsoft lists 3 different ways to get the definition of a view in SQL Server (also see this StackOverflow question), f.e.
SELECT definition
FROM sys.sql_modules
WHERE object_id = OBJECT_ID('MY.TEST_VIEW');
But they all include CREATE VIEW in the output (which is usually fine) and I need the exact query, i.e. for
CREATE VIEW [MY].[TEST_VIEW] (COL /*unfortunately some comment containing `as` and brackets :) */)
AS
   SELECT 1
I only want
   SELECT 1
While it's always possible to write a small-ish parser to find the correct AS in the view definition, I'd rather prefer something akin to Oracle's DBA_VIEWS:
select TEXT from DBA_VIEWS where OWNER = 'MY' and VIEW_NAME = 'TEST_VIEW'
UPDATE Answer from Dan Guzman translated into vb.net
Imports System.Runtime.Serialization
Imports Microsoft.SqlServer.TransactSql.ScriptDom
<CLSCompliant(False)>
Public Class ViewSelectStatementExtractor : Inherits TSqlFragmentVisitor
    Private SelectStatement As String
    'visitor method invoked for each CREATE VIEW statement in script
    Public Overrides Sub Visit(fragment As CreateViewStatement)
        Dim selectStatementFragment = fragment.SelectStatement
        'extract SELECT statement text from tokens
        Using sw = New IO.StringWriter
            For i = selectStatementFragment.FirstTokenIndex To selectStatementFragment.LastTokenIndex
                sw.Write(selectStatementFragment.ScriptTokenStream(i).Text)
            Next
            Me.SelectStatement = sw.ToString()
        End Using
    End Sub
    'Get view SELECT statement Using T-SQL script dom parser and visitor
    Shared Function Extract(createViewStatement As String) As String
        Dim parser = New Microsoft.SqlServer.TransactSql.ScriptDom.TSql150Parser(True)
        Dim parseErrors As IList(Of ParseError) = New List(Of ParseError)
        Dim fragment As TSqlFragment
        Using stringReader = New IO.StringReader(createViewStatement)
            fragment = parser.Parse(stringReader, parseErrors)
        End Using
        If (parseErrors.Count > 0) Then
            Dim errorStrings = From e In parseErrors Select $"{e.Line},{e.Column}: {e.Message}"
            Throw New ParseTSqlException($"{parseErrors.Count} parsing errors: {vbNewLine}{String.Join(vbNewLine, errorStrings)}")
        End If
        Dim visitor = New ViewSelectStatementExtractor
        fragment.Accept(visitor)
        Return visitor.SelectStatement
    End Function
End Class
<Serializable>
Public Class ParseTSqlException
    Inherits Exception
    Public Sub New()
    End Sub
    Public Sub New(message As String)
        MyBase.New(message)
    End Sub
    Public Sub New(message As String, innerException As Exception)
        MyBase.New(message, innerException)
    End Sub
    Protected Sub New(info As SerializationInfo, context As StreamingContext)
        MyBase.New(info, context)
    End Sub
End Class
 
    