Application of SQL Server2000 database system table

Source: Internet
Author: User

1: Get all the user tables in the current database

Select Name from sysobjects where xtype= ' u ' and status>=0

2: Get all the fields of a table

Select name from syscolumns where id=object_id (' Table name ')

3: View the views, stored procedures, functions associated with a table

Select a.* from sysobjects A, syscomments b where a.id = b.ID and b.text like '% table name '

4: View all stored procedures in the current database

Select name as stored procedure name from sysobjects where xtype= ' P '

5: Querying all databases created by the user

SELECT * FROM Master. sysdatabases D where Sid not in (select Sid from Master. syslogins where name= ' sa ')

Or

Select dbid, name as Db_name from master. sysdatabases where Sid <> 0x01

6: Querying the fields and data types of a table

Select Column_name,data_type from Information_schema.columns

WHERE table_name = ' table name '

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.