My lovely developers like to chanllenge my scripting skills. Today I was asked to restore one database on Dev server by using the backup taken from Prod. However, they wanted to keep all the store process in Dev. In order to avoid the store procs were removed during the dateabase restoring by prod backup, I had to script them out and then run them after restoring completed. The following codes help me to do that in one go without repeating the same process.
SET NOCOUNT ON
DECLARE @SP TABLE ( Id INT IDENTITY (1, 1),
Code VARCHAR (MAX) );