当前位置:网站首页>SQL: How to parse Microsoft Transact-SQL Statements in C# and to match the column aliases of a view
SQL: How to parse Microsoft Transact-SQL Statements in C# and to match the column aliases of a view
2022-04-23 16:51:00 【Tassel 1990】
public static TSqlScript Convert(string sql, out string prettySql)
{
var hasQuotedIdentifiers = false;
var parser = new TSql100Parser(hasQuotedIdentifiers);
var options = new SqlScriptGeneratorOptions();
options.SqlVersion = SqlVersion.Sql100;
options.KeywordCasing = KeywordCasing.Uppercase;
options.MultilineSelectElementsList = true;
options.MultilineWherePredicatesList = true;
IScriptFragment fragment;
IList<ParseError> errors;
using (var sr = new StringReader(sql))
{
fragment = parser.Parse(sr, out errors);
}
if (errors != null && errors.Count > 0)
{
var errorMessage = new StringBuilder();
foreach (var error in errors)
{
errorMessage.Append(error.Message);
errorMessage.Append("offset " + error.Offset);
}
throw new ApplicationException(errorMessage.ToString());
}
new Sql100ScriptGenerator(options).GenerateScript(fragment, out prettySql);
var parsedSql = fragment as TSqlScript;
return parsedSql;
}
版权声明
本文为[Tassel 1990]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231359254009.html
边栏推荐
- Bytevcharts visual chart library, I have everything you want
- Use case labeling mechanism of robot framework
- Path environment variable
- DanceNN:字节自研千亿级规模文件元数据存储系统概述
- Detailed explanation of information abstract, digital signature, digital certificate, symmetric encryption and asymmetric encryption
- Pseudo Distributed installation spark
- MySQL master-slave configuration under CentOS
- Deeply understand the relevant knowledge of 3D model (modeling, material mapping, UV, normal), and the difference between displacement mapping, bump mapping and normal mapping
- Change the password after installing MySQL in Linux
- 5分钟NLP:Text-To-Text Transfer Transformer (T5)统一的文本到文本任务模型
猜你喜欢
网络安全之渗透靶场实战详解
Smart doc + Torna generate interface document
阿里研发三面,面试官一套组合拳让我当场懵逼
MySQL master-slave synchronization pit avoidance version tutorial
Take according to the actual situation, classify and summarize once every three levels, and see the figure to know the demand
MySql主从复制
如何建立 TikTok用户信任并拉动粉丝增长
Loggie source code analysis source file module backbone analysis
ACL 2022 | dialogved: a pre trained implicit variable encoding decoding model for dialogue reply generation
安装及管理程序
随机推荐
面试百分百问到的进程,你究竟了解多少
Regular filtering of Intranet addresses and segments
Set cell filling and ranking method according to the size of the value in the soft report
【PIMF】OpenHarmony啃论文俱乐部—在ACM Survey闲逛是什么体验
人脸识别框架之dlib
计组 | 【七 输入/输出系统】知识点与例题
批量制造测试数据的思路,附源码
TypeError: set_ figure_ params() got an unexpected keyword argument ‘figsize‘
文件操作详解(2)
Gartner 發布新興技術研究:深入洞悉元宇宙
DDT + Excel for interface test
Creation of RAID disk array and RAID5
Path environment variable
PHP高效读大文件处理数据
On the security of key passing and digital signature
Nacos detailed explanation, something
Use if else to judge in sail software - use the title condition to judge
Execution plan calculation for different time types
Calculate pie chart percentage
阿里研发三面,面试官一套组合拳让我当场懵逼