zoukankan      html  css  js  c++  java
  • TSQL Parser

    
    // /r:"C:\Program Files\Microsoft Visual Studio 10.0\VSTSDB\Deploy\Microsoft.Data.Schema.ScriptDom.dll";"C:\Program Files\Microsoft Visual Studio 10.0\VSTSDB\Deploy\Microsoft.Data.Schema.ScriptDom.Sql.dll"
    namespace Microshaoft
    {
        using System;
        using System.Collections.Generic;
        using System.IO;
        using Microsoft.Data.Schema.ScriptDom;
        using Microsoft.Data.Schema.ScriptDom.Sql;
        public class Class1
        {
            static void Main(string[] args)
            {
                //SqlScriptGeneratorOptions options = new SqlScriptGeneratorOptions();
                //options.SqlVersion = SqlVersion.Sql100;
                //options.KeywordCasing = KeywordCasing.Uppercase;
                //Sql100ScriptGenerator scriptGenerator = new Sql100ScriptGenerator(options);
                SqlScriptGenerator scriptGenerator = new Sql100ScriptGenerator();
                TSqlParser parser = new TSql100Parser(false);
                IList<ParseError> errors;
                string sql =
    @"
                        --SELECT * FROM [from] WHERE ID='1'
                        select a.id,MAX(a.name),a.Name
                        from sysobjects aa
                        left join syscomments b
                        on a.id = b.id
                        where a.xtype = 'p'
                        and b.[text] like '% exec%'
                        group by a.id
    ";
                using (StringReader reader = new StringReader(sql))
                {
                    IScriptFragment fragment = parser.Parse(reader, out errors);
                    if (errors != null && errors.Count > 0)
                    {
                        foreach(ParseError pe in errors)
                        {
                            Console.WriteLine(pe.Message);
                        }
                    }
                    else
                    {
                        string script;
                        scriptGenerator.GenerateScript(fragment, out script);
                        Console.WriteLine(script);
                    }
                }
                Console.WriteLine(Environment.Version.ToString());
            }
        }
    }
    
    
  • 相关阅读:
    树的直径
    Codeforces 734E Anton and Tree(缩点+树的直径)
    Codeforces 948D Perfect Security(字典树)
    Codeforces 954D Fight Against Traffic(BFS 最短路)
    Codeforces 954C Matrix Walk (思维)
    Codeforces 950D A Leapfrog in the Array (思维)
    Codeforces 946D
    Invitation Cards POJ-1511 (spfa)
    spfa 单源最短路究极算法
    Currency Exchange POJ
  • 原文地址:https://www.cnblogs.com/Microshaoft/p/1949409.html
Copyright © 2011-2022 走看看