简体   繁体   English

如何在c#.net窗口中获取存储过程的所有代码并在c#.net窗口中创建存储过程的textFile

[英]how to get all code of stored procedure in c#.net window and create textFile of storedprocedure in C#.net window Application

我想从数据库中获取存储过程的所有代码,并将该过程转换为文本文件,然后将该文本文件保存在c#.net窗口应用程序的特定路径中。

With thanks to David Cumps (Assuming SQL Server): 感谢David Cumps (假设使用SQL Server):

SELECT text 
FROM syscomments 
WHERE id = (SELECT id FROM sysobjects WHERE name = '{0}') 
ORDER BY colid

Execute this query from your app then concatenate the results. 从您的应用程序执行此查询,然后连接结果。

In order to get the code for a stored procedure, you're probably going to have to query the system tables in the database. 为了获取存储过程的代码,您可能必须查询数据库中的系统表。 Look at the documentation for whatever RDBMS you're using. 查看文档以了解所使用的RDBMS。

As far as saving a text file goes, take a look at this howto . 至于保存文本文件,请看一下该howto

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM