SQL Server is one of the most common applications: getting basic table information, Field List, Stored Procedure Parameter List

Source: Internet
Author: User

 

Recommendation]SQL Server One of the uncommon applications

Obtains the basic information, Field List, and stored procedure parameter list of a table.

 

-- Establish a personal brand through knowledge sharing.

 

1. obtain basic table information

 
Select [tablename] = [Tables]. name, [tableowner] = [schemas]. name, [tablecreatedate] = [Tables]. create_date, [tablemodifydate] = [Tables]. modify_datefrom sys. tables as [Tables] inner join sys. schemas as [schemas] on [Tables]. schema_id = [schemas]. schema_idwhere [Tables]. name = 'file directory'

 

Result 1:

 

Figure 1 Specify basic table information

 

2. Obtain the field list based on the table name

 

Select [columnname] = [columns]. name, [systemtypename] = [Types]. name, [precision] = [columns]. precision, [scale] = [columns]. scale, [maxlength] = [columns]. max_length, [isnullable] = [columns]. is_nullable, [isrowguidcol] = [columns]. is_rowguidcol, [isidentity] = [columns]. is_identity, [iscomputed] = [columns]. is_computed, [isxmldocument] = [columns]. is_xml_document, [description] = [properties]. valuefrom sys. tables as [Tables] inner join sys. columns as [columns] on [Tables]. object_id = [columns]. object_id inner join sys. types as [Types] on [columns]. system_type_id = [Types]. system_type_id and is_user_defined = 0 and [Types]. name <> 'sysname' left Outer Join sys. extended_properties as [properties] on [properties]. major_id = [Tables]. object_id and [properties]. minor_id = [columns]. column_id and [properties]. name = 'Ms _ description' where [Tables]. name = file directory order by [columns]. column_id

 

Result 2:

Figure 2 Field list information of the specified table

 

 

3. Obtain the list of specified stored procedure parameters

 

 
Select SC. name as parameter name, St. name as type, SC. length as length from syscolumns SC inner join sysobjects so on so. id = SC. id inner join policypes st on SC. xtype = ST. xtypewhere so. name = 'SP _ pagination'

Effect 3:

Figure 3 List of parameters for a stored procedure

 

 

2012Erichu

For original works, please refer to the author and source for the post. Leave this information.

 

------------------------------------------------

cnblobs: http://www.cnblogs.com/huyong/
csdn : http://blog.csdn.net/chinahuyong

 

Author: Erichu ( DB , C \ s , B \ s , WebService , WCF , PM )
Source 1: Http://www.cnblogs.com/huyong/

Source 2:Http://blog.csdn.net/chinahuyong

Q:80368704 E-mail: 80368704@qq.com

Q GROUP: 190401986
You are welcome to browse and repost this blog post, but this statement must be retained without the consent of the author.ArticleThe original Article connection is clearly displayed on the page. In the reference article, I will indicate the source of the reference article and respect the copyright of others. If you find that I infringe your copyright, please contact me in time.
For more articles, see [ top ] index stickers -- (update continuously)

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.