dimanche 15 mars 2015

Get object script in SQL Server via T-SQL?


I need to get the creation script of an object in a SQL Server database. I need the exact same script that was used to create it. Like when you use SSMS to alter a view you already defined, and then the script is there, just the way you've defined it earlier.


I need to do this in T-SQL. Where does SQL Server store the scripts related to the database objects? I can't find the related view in system catalog views.


What I'm trying to find is something like:



select creation_script -- I know this column doesn't exist
from sys.objects
where name = 'CustomersView'




Aucun commentaire:

Enregistrer un commentaire