|Encapsulate as View|
The Encapsulate as View command converts the selected code into a new view and optionally replace it with a SELECT from the new view.
This topic contains the following sections:
Only single SELECT statements which do not reference variables can be encapsulated as views. SELECT INTO and SELECT @local_variable statements are not allowed.
To encapsulate code as a new view:
1. Select the script that you want to use for the new view.
2. On the SQL Enlight->Refactor menu, click Encapsulate as View .
3. The Encapsulate as View dialog box is displayed.The SQL script for the creation of the view is displayed in the Preview box.
4. Type the name of the owner in the Owner edit box.
5. Type the name of the function in the Name edit box.
The view name is not checked for duplicate names. If a view with this schema and name already exists, the script will fail.
6. Review the generated script in the Preview box and modify it if necessary.
7. Select Modify source script to reference the new object if you want SQL Enlight to modify the originating script and replace the encapsulated code with reference to the new function. The generated reference to the new view is an SELECT statement:
1SELECT * 2FROM [dbo].[NewView]
8. Click Apply button to apply the changes.