問題描述
我想將所有存儲過程從 SQL Server 2012 編寫為 .sql
文件(在不同的項目中)到 Visual Studio 2012.我怎么做?每個存儲過程都需要一個 .sql 文件嗎?在 SQL Server 2012 中右鍵單擊 DB 后,我使用在任務中生成腳本"選項獲取腳本.但是,在每種情況下,.sql 文件的名稱都是 spname.StoredProcedure.我希望名稱為 spname.sql.同樣,我不希望文件名是 database.spname.StoredProcedure,我希望它只是 spname.sql
請查看以下 SQL 教程,了解如何
另外在生成腳本向導中,如果您配置如下圖所示的選擇選項,您將得到 sp 名稱作為輸出腳本文件名
I want to script all the stored procedures from SQL Server 2012 to Visual Studio 2012 as .sql
files (in a different project). How do I do that? I want one .sql file for each stored procedure?
I get the scripts using the Generate Scripts in Tasks option after right clicking DB in SQL Server 2012. However, the name of the .sql file is spname.StoredProcedure in each case. I want the name to be spname.sql.
Again I don't want the file name to be database.spname.StoredProcedure, I want it to be just spname.sql
Please check following SQL tutorial showing how to generate a separate script file for each stored procedure in a SQL Server database
The solution uses sp_Helptext stored procedure with SQL BCP command for generating create script for target SP and then create the export .sql file on the file system.
I hope it helps,
Additionally on generate script wizard, if you configure selection options as seen in below picture, you will get the sp name as the output script file name
這篇關于SQL Server 2012:如何將所有數據庫存儲過程編寫成單獨的 .sql 文件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!