Hi All,
We have the one procedure sp_MSforeachdb which is used to execute the script in all the databases at a time.
Below is the script for getting the strored Procedures defintion in all the databases.
EXECUTE master.sys.sp_MSforeachdb ‘USE [?]; select @@SERVERNAME as servername,DB_NAME() as [Database],so.name,sc.text
from sysobjects (nolock) so inner join
syscomments(nolock) sc
on
sc.id=so.id
where so.type=”p”’
Result:
but the Procedure sp_MSforeachdb is un documented stored Procedure and there us no Gaurranty from Microsoft for future versions usage and this is Microsoft internal purpose only
if you want stored procedure definition from database, use the below script
use YouRdatabase
select @@SERVERNAME as servername,DB_NAME() as [Database],so.name,sc.text
from sysobjects (nolock) so inner join
syscomments(nolock) sc
on
sc.id=so.id
where so.type=’p’
Result:
Thanks for viewing and let us know if you have other options also .
Regards,
Chaitanya,
Webiste : https://mssqlbuzz.wordpress.com/
To Send Mail : mssqlbuzz
Its showing in correct insyntax error bro(all database script)
LikeLike