Creating a viewscript

From Species File Help
Jump to: navigation, search

Creating a viewscript

This is a new simpler way to create a viewscript that will not break when using the Apex Taxon tools and will provide better feedback if an error occurs. (7/16/13 EEF & JRF)

In order to create or update a view:

  • Design (or edit) the view in SSMS. Once you are satisfied with the view; create a viewscript by using the "ALTER" to clipboard command. (Right click on saved view in the object explorer, => Script View as => ALTER To => Clipboard)
  • Create (or edit) your viewscript file in Visual Studio. All the view scripts are kept in the SQL project in the "ViewScripts" directory. Your view name (and filename) should start with "view". The file type is SQL. There is no view template, but the file should have some of the same header as any other SQL file (see Common/Support/ProgrammingRelated/FileTemplates/spTemplate.sql). Included fields should be:
    • Copyright
    • File
    • Name
    • Desc (description)
    • Auth (author)
    • Date
    • Change History
  • Paste the clipboard code from SSMS into the section after the header comments.
  • Delete the segments that set the database. (e.g.
    USE [Lygaeoidea1]
    GO

    )

  • Delete the code that sets ANSI_NULLS and QUOTED_IDENTIFIER. This is set in the Apex Taxon utilities that will update the scripts in the database. (e.g.
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO

    )

  • Delete the final "GO" at the bottom of the script.

Your viewscript it now complete and can be returned to source control. You can run the script to update the view in the db or it will be updated the next time full builds are done and database objects are updated.

Personal tools
Namespaces

Variants
Actions
Navigation
Species Files
Wiki
Toolbox