Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Backup of All Stored Procedures in .SQL files

Author  Topic 

ssnaik84
Starting Member

15 Posts

Posted - 2008-11-13 : 00:04:10
Hello,
We are in the phase of migration of MS-SQL Server to MySQL as per client requirement. By using migration tool, we have migrated almost all DB objects, excepts SPs. We have developed a parser to translate MS-SQL SPs to MySQL.
But, It needs to have all MS-SQL SPs backup (in separate .sql files)
How can we get all SPs backup in .sql files? (one .sql file per SP)

cvraghu
Posting Yak Master

187 Posts

Posted - 2008-11-13 : 00:43:50
You can right click database objects and script out all procedures into a single file. But to make each sp in a single file, you may have to manually split the file. or write some code.
Go to Top of Page

karthickbabu
Posting Yak Master

151 Posts

Posted - 2008-11-13 : 06:34:42


DECLARE @Sql varchar(8000)
SET @Sql = 'EXEC Master..XP_CmdShell ''bcp "SELECT Routine_Definition FROM YourDBName.Information_Schema.Routines" queryout "C:\Script.sql" -c'''
EXEC (@Sql)



================================================

When you realize you've made a mistake, take immediate steps to correct it.
Go to Top of Page

karthickbabu
Posting Yak Master

151 Posts

Posted - 2008-11-13 : 23:30:15

See this link

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=114398

================================================

When you realize you've made a mistake, take immediate steps to correct it.
Go to Top of Page

ssunny
Posting Yak Master

133 Posts

Posted - 2008-11-14 : 14:21:58
To generate script for all sp, right click on database,generate script,select all store procedures in General tab. Now go to options tab and under file options select create one file per object option.This will create one file per sp in .PRC format then rename *.PRC to *.sql.
Go to Top of Page
   

- Advertisement -