开发者

How to run sql from a .net application against sqlserver and get output like with SQL Management Studio?

开发者 https://www.devze.com 2022-12-27 07:01 出处:网络
I\'d like my app to run sql files and receive the results output as if the sql was run from SQL Management Studio with results to text. i.e. nicely formatted recordsets, printed messages, rows affecte

I'd like my app to run sql files and receive the results output as if the sql was run from SQL Management Studio with results to text. i.e. nicely formatted recordsets, printed messages, rows affected, errors, running multiple batches separated by GO statements, etc. Any suggestions how开发者_运维百科 to do this without building it from scratch on top of a normal SQL connection?

I'm using C# .NET


You don't say what language your application is written in, but if you're using .Net, you might get some help from the source code for QueryExPlus, a lightweight OSS alternative to SSMS.


Probably the easiest is to use GetXml() method of dataset and then apply XSLT transformation to produce the desired result.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号