Monday, 31 July 2017

Generate create scripts for Procedure, Views and Function in sql server

Using below sql script we will get the create script for procedure, view and function.
SELECT
CASE WHEN o.type ='FN' Then 'Function'
                 WHEN o.type ='P' Then 'Procedure'
                 WHEN o.type ='V' Then 'View'
                 END as 'create scripts ',
m.definition
FROM sys.sql_modules m
INNER JOIN sys.Objects o
ON m.Object_id = o.Object_id
WHERE o.type IN('FN','P','V')

Executing this script
  
We can copy this script and run this query object will created
 



No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts