I lost the script for a view that I created. Can I retrieve / recreate the script from the database using management studio?
Right-click the SQL connection and then click Insert Script Files. The Open dialog box opens. 4. Select the SQL script file (.
With the Views node highlighted in Object Explorer, open Object Explorer Details ( F8 or Shift + F8 if I recall correctly). This will open a window with all the views in a list, and you highlight the views you want and right-click > script.
You can also retrieve this information by querying the sys.sql_modules dynamic management view:
Here's an example:
USE AdventureWorks
GO
SELECT DEFINITION
FROM sys.sql_modules
WHERE object_id = OBJECT_ID('HumanResources.vEmployee')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With