获取存储过程架构 [英] getting stored procedure schema

查看:108
本文介绍了获取存储过程架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想只得到存储过程的模式...不是数据,作为我的应用程序中的结果集...

任何人都知道如何获得模式?



在此先感谢...

I want to get only schema of stored procedure... Not data, as a result set in my application...
Anyone knows how could i get the schema?

Thanks in advance...

推荐答案

您需要执行命令并使用<$ c获取SP的架构$ c> SqlDataReader.GetSchemaTable()。

试试这个:

You need to execute the command and get the schema of SP using SqlDataReader.GetSchemaTable().
Try this:
public static DataTable SchemaReader(string tableName) 
{      
  conn.Open();      
  SqlCommand cmd = new SqlCommand("MyStoredProcedure", conn);
  cmd.CommandType = CommandType.StoredProcedure;      
  SqlDataReader reader = cmd.ExecuteReader();       
  DataTable schema = reader.GetSchemaTable();       
  reader.Close();      
  conn.Close();      
  return schema; 
}





--Amit



--Amit


你不想打电话给SP因为你可能会影响数据库中的一些数据。



相反:



You do not want to call the SP as you may affect some data in the DB.

Instead:

SELECT * FROM sys.dm_exec_describe_first_result_set ('owner.sprocName', NULL, 0) ;





返回结果集:





This returns the result set:

is_hidden
column_ordinal 
name
is_nullable 
system_type_id 
system_type_name    
max_length 
precision 
scale 
collation_name      
user_type_id 
user_type_database  
user_type_schema    
user_type_name      
assembly_qualified_type_name
xml_collection_id 
xml_collection_database
xml_collection_schema  
xml_collection_name    
is_xml_document 
is_case_sensitive 
is_fixed_length_clr_type 
source_server   
source_database 
source_schema   
source_table    
source_column   
is_identity_column 
is_part_of_unique_key 
is_updateable 
is_computed_column 
is_sparse_column_set 
ordinal_in_order_by_list 
order_by_is_descending 
order_by_list_length 
error_number 
error_severity 
error_state 
error_message 
error_type  
error_type_desc


这篇关于获取存储过程架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆