当前位置:网站首页>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
边栏推荐
- 织梦DEDECMS安全设置指南
- MySQL master-slave replication
- About background image gradient()!
- TypeError: set_figure_params() got an unexpected keyword argument ‘figsize‘
- Ali developed three sides, and the interviewer's set of combined punches made me confused on the spot
- LVM and disk quota
- 伪分布安装spark
- ByteVCharts可视化图表库,你想要的我都有
- RAID磁盘阵列与RAID5的创建
- Nodejs installation and environment configuration
猜你喜欢

Detailed explanation of Niuke - Gloves

Smart doc + Torna generate interface document

博士申请 | 厦门大学信息学院郭诗辉老师团队招收全奖博士/博后/实习生

TypeError: set_ figure_ params() got an unexpected keyword argument ‘figsize‘

The font of the soft cell changes color

Installation and management procedures

Nacos detailed explanation, something

Mock test using postman

ByteVCharts可视化图表库,你想要的我都有

OMNeT学习之新建工程
随机推荐
关于局域网如何组建介绍
Modify the test case name generated by DDT
5分钟NLP:Text-To-Text Transfer Transformer (T5)统一的文本到文本任务模型
英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
聊一聊浏览器缓存控制
STM32__ 03 - beginner timer
Deeply understand the relevant knowledge of 3D model (modeling, material mapping, UV, normal), and the difference between displacement mapping, bump mapping and normal mapping
Introduction to new functions of camtasia2022 software
PostgreSQL column storage and row storage
Construction of promtail + Loki + grafana log monitoring system
UWA Pipeline 功能详解|可视化配置自动测试
Mock test
MySQL master-slave replication
如何用Redis实现分布式锁?
计组 | 【七 输入/输出系统】知识点与例题
人脸识别框架之dlib
Pycham connects to the remote server and realizes remote debugging
5-minute NLP: text to text transfer transformer (T5) unified text to text task model
正则过滤内网地址和网段
PHP efficiently reads large files and processes data