当前位置:网站首页>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
边栏推荐
- Set cell filling and ranking method according to the size of the value in the soft report
- 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
- Solution of garbled code on idea console
- File upload and download of robot framework
- Mock test using postman
- DDT + Excel for interface test
- Use if else to judge in sail software - use the title condition to judge
- Qipengyuan horizon credible meta universe social system meets diversified consumption and social needs
- PHP efficiently reads large files and processes data
- ◰ GL shadow map core steps
猜你喜欢
随机推荐
众昂矿业:萤石浮选工艺
Real time operation of vim editor
Use if else to judge in sail software - use the title condition to judge
蓝桥杯省一之路06——第十二届省赛真题第二场
Change the password after installing MySQL in Linux
Execution plan calculation for different time types
Path environment variable
Server log analysis tool (identify, extract, merge, and count exception information)
Bytevcharts visual chart library, I have everything you want
VLAN高级技术,VLAN聚合,超级Super VLAN ,Sub VLAN
CentOS MySQL multi instance deployment
Flask如何在内存中缓存数据?
Custom implementation of Baidu image recognition (instead of aipocr)
计组 | 【七 输入/输出系统】知识点与例题
File system read and write performance test practice
无线鹅颈麦主播麦手持麦无线麦克风方案应当如何选择
Installing labellmg tutorial in Windows
Take according to the actual situation, classify and summarize once every three levels, and see the figure to know the demand
关于 background-image 渐变gradient()那些事!
Zhongang Mining: Fluorite Flotation Process