Skip to content

Parsing a ALTER TABLE ADD COLUMN statement returns NullSqlStatement #25

Description

@thommelutten

Hi there,
I'm trying to incorporate the SqlParser in a hobby project, but run into odd behavior when I try to parse an ALTER TABLE ADD COLUMN statement. It simply returns a Statement of type SqlNullStatement.

Code:

var input = "ALTER TABLE TestTable ADD TestColumn INT;";

ParseResult result = Microsoft.SqlServer.Management.SqlParser.Parser.Parser.Parse(input);
Console.WriteLine(result.Script.Children.First().Children.First().Statement.GetType()); // Outputs SqlNullStatement

I had hoped to get a specific statement identifier like I get with an Drop Table Statemnt:

var dropTableStatement = "DROP TABLE TestDb;";

ParseResult dropTableResult = Microsoft.SqlServer.Management.SqlParser.Parser.Parser.Parse(dropTableStatement);
Console.WriteLine(dropTableResult.Script.Children.First().Children.First().Statement.GetType()); // Outputs SqlDropTableStatement

Hope you can help shed some light into what I' doing wrong.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions