当前位置:网站首页>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
边栏推荐
- Cartoon: what are IAAs, PAAS, SaaS?
- Pycham connects to the remote server and realizes remote debugging
- Detailed explanation of Niuke - Gloves
- 计组 | 【七 输入/输出系统】知识点与例题
- Rtklib 2.4.3 source code Notes
- vscode如何比较两个文件的异同
- Use itextpdf to intercept the page to page of PDF document and divide it into pieces
- How to implement distributed locks with redis?
- ∑GL-透视投影矩阵的推导
- OMNeT学习之新建工程
猜你喜欢
English | day15, 16 x sentence true research daily sentence (clause disconnection, modification)
Project framework of robot framework
Detailed explanation of Niuke - Gloves
[pyGame games] how did angry birds, a mobile game that became popular all over the world 10 years ago, dominate the list? Classic return
ACL 2022 | DialogVED:用于对话回复生成的预训练隐变量编码-解码模型
Real time operation of vim editor
CentOS MySQL multi instance deployment
On the security of key passing and digital signature
Detailed explanation of information abstract, digital signature, digital certificate, symmetric encryption and asymmetric encryption
New project of OMNeT learning
随机推荐
DanceNN:字节自研千亿级规模文件元数据存储系统概述
VLAN高级技术,VLAN聚合,超级Super VLAN ,Sub VLAN
Selenium IDE and XPath installation of chrome plug-in
昆腾全双工数字无线收发芯片KT1605/KT1606/KT1607/KT1608适用对讲机方案
PHP高效读大文件处理数据
Zhimeng dedecms security setup Guide
Derivation of Σ GL perspective projection matrix
详解牛客----手套
The new MySQL table has a self increasing ID of 20 bits. The reason is
Use case labeling mechanism of robot framework
深入了解3D模型相关知识(建模、材质贴图、UV、法线),置换贴图、凹凸贴图与法线贴图的区别
Set the color change of interlaced lines in cells in the sail software and the font becomes larger and red when the number is greater than 100
Use itextpdf to intercept the page to page of PDF document and divide it into pieces
Feign report 400 processing
MySql主从复制
ByteVCharts可视化图表库,你想要的我都有
Installing labellmg tutorial in Windows
Detailed explanation of the penetration of network security in the shooting range
MySQL personal learning summary
STM32__ 03 - beginner timer