【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)