Obtain the script information in the database.

Source: Internet
Author: User
Set nocount on; --/* -- = ==== -- job -- server/jobserver/job [@ name = '{1}'] selecturn = n' server/jobserver/job [@ name = '+ quotename (name, n''') + N'] ', script_file = nullfrom MSDB. DBO. sysjobs job with (nolock) where job. category_id in (-- not include replication jobselect cat. category_idfrom MSDB. DBO. syscategories cat with (nolock) where Cat. category_class = 1and cat. name not in (N 'Log shipping') and CAT. name Not Like N 'repl-% ') and enabled = 1 -- not include disable job; -- ===================================================== = * // * -- ========================================== ====== -- schema -- server/database [@ name = '{0}']/Schema [@ name = '{1}'] selecturn = n' server' + N'/database [@ name = '+ quotename (db_name (), N ''') + N'] '+ N'/Schema [@ name =' + quotename (obj. name, n''') + N'] ', script_file = nullfrom sys. schemas OBJ with (nolock) Inner join sys. database_principals DP with (nolock) on DP. principal_id = obj. principal_idwhere DP. type in ('s', 'U', 'G', 'C', 'k') and obj. name not in (N 'dbo', N 'sys ', N 'guest', N 'information _ scheme') and obj. name Not Like n' % mark % Delete % 'and not (obj. name = DP. nameand obj. name like n' % dbo '); -- ===================================================== = * // * -- ========================================== ====== -- tables -- server/database [@ name = '{0}']/table [@ name = '{1}' and @ schema = '{2} '] selecturn = n 'server' + N'/database [@ name =' + quotename (db_name (), N ''') + N'] '+ N'/table [@ name =' + quotename (obj. name, n''') + N' and @ schema = '+ quotename (Sch. name, n''') + N'] ', script_file = Sch. name + N '. '+ obj. namefrom sys. tables OBJ with (nolock) Inner join sys. schemas Sch with (nolock) on Sch. schema_id = obj. schema_idwhere obj. is_ms_shipped = 0and obj. name Not Like n' % mark % Delete % '-- and Sch. name = n 'dbo '; -- ===================================================== = * // * -- ========================================== ====== -- Views -- server/database [@ name = '{0}']/view [@ name = '{1}' and @ schema = '{2} '] selecturn = n 'server' + N'/database [@ name =' + quotename (db_name (), N ''') + N'] '+ N'/view [@ name =' + quotename (obj. name, n''') + N' and @ schema = '+ quotename (Sch. name, n''') + N'] ', script_file = Sch. name + N '. '+ obj. namefrom sys. views OBJ with (nolock) Inner join sys. schemas Sch with (nolock) on Sch. schema_id = obj. schema_idwhere obj. is_ms_shipped = 0and obj. name Not Like n' % mark % Delete % '-- and Sch. name = n 'dbo '; -- ===================================================== = * // * -- ========================================== ====== -- functions -- server/database [@ name = '{0}']/userdefinedfunction [@ name = '{1}' and @ schema = '{2} '] selecturn = n 'server' + N'/database [@ name =' + quotename (db_name (), N ''') + N'] '+ N'/userdefinedfunction [@ name =' + quotename (obj. name, n''') + N' and @ schema = '+ quotename (Sch. name, n''') + N'] ', script_file = Sch. name + N '. '+ obj. namefrom sys. objects OBJ with (nolock) Inner join sys. schemas Sch with (nolock) on Sch. schema_id = obj. schema_idwhere obj. type in ('tf', 'fn ', 'if', 'fs', 'ft', 'af') and obj. is_ms_shipped = 0and obj. name Not Like n' % mark % Delete % '-- and Sch. name = n 'dbo '; -- ===================================================== = * // * -- ========================================== ====== -- procedures -- server/database [@ name = '{0}']/storedprocedure [@ name = '{1}' and @ schema = '{2} '] selecturn = n 'server' + N'/database [@ name =' + quotename (db_name (), N ''') + N'] '+ N'/storedprocedure [@ name =' + quotename (obj. name, n''') + N' and @ schema = '+ quotename (Sch. name, n''') + N'] ', script_file = Sch. name + N '. '+ obj. namefrom sys. procedures OBJ with (nolock) Inner join sys. schemas Sch with (nolock) on Sch. schema_id = obj. schema_idwhere obj. is_ms_shipped = 0and obj. name Not Like n' % mark % Delete % '-- and Sch. name = n 'dbo '; -- ===================================================== = */

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.