SQL Server Database SP Command Xiang Solution

Source: Internet
Author: User

1, Database:

(1) sp_helpdb: Reports information about a specified database or all databases.
Example: sp_helpdb--Display all database information (name, size, etc.)
Example: sp_helpdb Recruitment--Display recruitment database information (name, size, etc.)

(2) Sp_renamedb: Change the name of the database.
Example: Sp_renamedb ' pubs ', ' pub '--renaming a database named pubs to pub

(3) sp_dboption: Display or change database options. You cannot use sp_dboption on the master or tempdb database.
Example: sp_dboption ' recruitment ', ' Read Only ', ' TRUE '--Set the recruitment database to read only

2, table

(1)sp_help: Finds objects in the current database.
Cases:sp_helpEmployee--Displays the structure of the employee table

(2) Sp_rename: Changes the name of a user-created object (such as a table, column, or user-defined data type) in the current database.
Example: sp_rename ' employee ', ' employ '

3, user-defined data types

(1) sp_addtype: Create a user-defined data type.
Example: sp_addtype birthday, datetime, ' NULL '
--created a user-defined data type named Birthday (DateTime based) that allows null values for the data type

(2) Sp_droptype: Delete user-defined data types.
Example: Sp_droptype ' birthday '--delete a user-defined data type birthday

(3)sp_help: View user-defined data types
Cases:sp_helpBirthday--View information for user-defined data types birthday

4, Rules

(1) Sp_bindrule: Binds a rule to a column or user-defined data type.
Example: Sp_bindrule rultype, ' titles.type '--binding the rule Rultype to the Type column of the Titles table

(2) Sp_unbindrule: Unbind a rule from a column or user-defined data type in the current database.
Example: Sp_unbindrule ' Titles.type '--unbind a rule from a Type column in a tiltes table

(3) Sp_helptext: View the details of the rule.
Example: Sp_helptext rultype--View details of a rule rultype

5, default

(1) Sp_bindefault: Binds the default value to a column or user-defined data type.
(2) Sp_unbindefault: Removes (deletes) the default value bindings for a column or user-defined data type in the current database.
(3) Sp_helptext: View the default value information.

6, Index

Sp_helpindex: Reports information about indexes on a table or view.
Example: Sp_helpindex employee--View index information in employee table

7, Views

Sp_helptext: Viewing the view text

8, stored Procedures

sp_helptext: viewing stored procedure text

9, triggers

(1)sp_help< trigger name;: To see if the specified trigger exists
(2) Sp_helptrigger: Returns the trigger type for the current database defined in the specified table.

Ten, other

sp_help: Reports information about database objects, user-defined data types, or data types.
Sp_helptext: Displays the text of a rule, default value, unencrypted stored procedure, user-defined function, trigger, or view.
sp_rename: Changes the name of a user-created object (such as a table, column, or user-defined data type) in the current database.

SQL Server Database SP Command Xiang Solution

Related Article

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.