SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to Export Stored Procedures to Text Files?


How to Export Stored Procedures to Text Files?

Author
Message
Nisha G
Nisha G
SSC Journeyman
SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)

Group: General Forum Members
Points: 75 Visits: 1

I have over 100 Stored Procedures in my database and would like to know how to export them to text files as a backup? (Not the output data of the Stored Procedure, but the Stored Procedure itself.)

Please help! Thank you


sushila
sushila
SSCrazy Eights
SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)

Group: General Forum Members
Points: 8537 Visits: 639
Nisha - you can use enterprise manager and the scripting wizard to script the text either into individual files or all stored procedures in one big file and then print them out!

if you right click on the database - go to "all tasks" - generate sql scripts - you can then enter your specs in each tab...under the options tab you can check either the "create one file" or "create one file per object"!

hth!







**ASCII stupid question, get a stupid ANSI !!!**
ALZDBA
ALZDBA
SSC-Dedicated
SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)

Group: General Forum Members
Points: 30371 Visits: 8986

Check uot SQLDMO is BOL.

It has scripting capabilities.



Johan


Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere w00t

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


press F1 for solution, press shift+F1 for urgent solution :-D


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me Alien but most of the time this is me Hehe
ALZDBA
ALZDBA
SSC-Dedicated
SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)

Group: General Forum Members
Points: 30371 Visits: 8986

Check uot SQLDMO is BOL.

It has scripting capabilities.



Johan


Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere w00t

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


press F1 for solution, press shift+F1 for urgent solution :-D


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me Alien but most of the time this is me Hehe
Nisha G
Nisha G
SSC Journeyman
SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)

Group: General Forum Members
Points: 75 Visits: 1

Sushila, Thanks a ton! I hadn't explored the option you mentioned.

It worked and I've gained more SQL knowledge. Thank U once again


sushila
sushila
SSCrazy Eights
SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)

Group: General Forum Members
Points: 8537 Visits: 639
anytime!







**ASCII stupid question, get a stupid ANSI !!!**
Hemantgiri S. Goswami
Hemantgiri S. Goswami
SSC-Enthusiastic
SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)SSC-Enthusiastic (142 reputation)

Group: General Forum Members
Points: 142 Visits: 228

for an instance you can do it other alternet way too use L:

sp_helptext 'yrspname' it will display the text / code of yr sp copy / save it to .txt file .

HTH

Regards.



Hemantgiri S. Goswami | SQL Server Specialist & Consultant
SQL Server Citation | Follow me on Twitter
Noman Salim
Noman Salim
Valued Member
Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)Valued Member (52 reputation)

Group: General Forum Members
Points: 52 Visits: 21
Following up on the solution provided by Sushila, is there a way to script all stored procedures in the database to seperate files with the same names as the stored procedures?

This is driving me nuts. The method provided by Sushila can script the SPs to a file one by one or all at once in a single file, but can I do all of them together in seprate files with the same names as original.
rcavill
rcavill
SSC-Addicted
SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)SSC-Addicted (470 reputation)

Group: General Forum Members
Points: 470 Visits: 852
From within SQL-EM, highlight the list of stored procedures within the database.
After right click and choosing Tasks-->Generate SQL Scripts, the "Generate SQL Scripts" window appears.
the [General] tab will show those objects to be scripted
switch to the [Options] tab. The bottom right corner has an option to script all selected objects as one file or one file per object.

When you click the OK button it will ask for the folder into which each file will be saved. stored procedures will have a .PRC extension
-----
Robert



sushila
sushila
SSCrazy Eights
SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)

Group: General Forum Members
Points: 8537 Visits: 639
In addition to Robert's post I just wanted to mention that the Help provided with SQL Server (BOL - Books on line) is pretty extensive & comprehensive and that's usually the first place I would look for solutions!Smile







**ASCII stupid question, get a stupid ANSI !!!**
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search