I need to get attribute information (name, type, null/not null, constraints) from CREATE TABLE
script, but I can't find any libraries or frameworks for it. I checked this one but this parser doesn't get information about table being created. Are there ways to do this without manual parsing?
My app doesn't use DB. The information should be extracted from the script text.
For example, from this script
CREATE TABLE [dbo].[person]
(
[id] [int] NOT NULL ,
[Name] [VARCHAR](1) NULL,
[fk] [int] NULL,
CONSTRAINT [PK_person]
PRIMARY KEY CLUSTERED ([id])
)
I need to extract the following information:
strgin tblName = ParseResult.TableName; //"person"
Attribute a0 = ParseResult.Attr[0]; //Attribute{"id", "int" "NOT NULL", "PK"}
Attribute a1 = ParseResult.Attr[1];
Attribute a2 = ParseResult.Attr[2];