Today I came across one scenario where I need to get the stored procedure definition from the Admin panel of the DNN(Dot Net Nuke) site with out opening the SQL Server, which is possible using below query,
- select definition
- rom sys.Sql_modules
- where object_id=object_ID('YourSchemaname.ProcedureName')
For Example,
I have Test database which consist of userprofile table and the stored procedure Usp_GetUser as show in below figure
The definition of the procedure Usp_GetUser
- ALTER procedure [dbo].[Usp_GetUser]
- as
- begin
- select*From UserProfile
- end
Now we are going the see how to get the definition of the above procedure using the query,
- select definition
- from sys.Sql_modules
- where object_id=object_ID('dbo.Usp_GetUser')
Result
I hope you enjoyed this blog. Your valuable feedback, question, or comments about this blog are always welcomed.