System table collection and usage collection

Source: Internet
Author: User

1. sysobjects system table: each object (such as constraints, default values, logs, rules, and stored procedures) created in the database corresponds to a row.
2. syscolumns system table: returns a row for each column in each table and view, and returns a row for each parameter in the database stored procedure.
3. syscomments system table: contains items for each view, rule, default value, trigger, check constraint, default constraint, and stored procedure in the database. The text column contains the original SQL Definition Statement. The maximum size of these statements is 4 MB.

 

-- Determine whether a stored procedure exists
If exists (select * From DBO. sysobjects where id = object_id (n' [DBO]. [sp_sel_tr_tdt] ') and objectproperty (ID, n' isprocedure') = 1)
Begin
Drop procedure sp_sel_tr_tdt
End

-- Determine whether a user table exists
If exists (select * From DBO. sysobjects where id = object_id (n' [DBO]. [lc_location] ') and objectproperty (ID, n'isusertable') = 1)
Begin
-- Execute the operation
End

-- Determine whether a system table exists
If exists (select * From DBO. sysobjects where id = object_id (n' [DBO]. [lc_location] ') and objectproperty (ID, n'issystemtable') = 1)
Begin
-- Execute the operation
End

-- Determine whether a Column exists in the User table
If exists (select * From syscolumns where name = 'lc _ opendate' and ID in (select ID from DBO. sysobjects where id = object_id (n' [DBO]. [lc_location] ') and objectproperty (ID, N 'isusertable') = 1 ))
Begin
-- Execute the operation
End

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.