请问怎么保存sp_的结果啊?
请问各位大虾,怎么保存sp_XXX之类的系统过程,分类存储过程的结果?比如保存在数据表内,或者赋给变量 <p>SP有什么结果?存储过程就是标准的TXT文本,存成TXT或SQL就行了,用记事本可以直接打开或编辑。</p> <p>以sp_help为例子:获得了sp_help的源代码.可以自己分析改造</p><p>sp_helptext sp_help </p><p>/* Sccsid = "%Z% generic/sproc/%M% %I% %G%" */<br/>/* 4.8 1.1 06/14/90 sproc/src/help */<br/>/*<br/>** Messages for "sp_help" 17570<br/>**<br/>** 17460, "Object must be in the current database."<br/>** 17461, "Object does not exist in this database."<br/>** 17570, "Operating System File"<br/>** 17571, "---------------------"<br/>** 17573, "Object is Remote/External"<br/>** 17574, "-------------------------"<br/>** 17575, "Object existed prior to Omni"<br/>** 17576, "Lock scheme is Allpages" <br/>** 17577, "Lock scheme is Datapages"<br/>** 17578, "Lock scheme is Datarows" <br/>** 17579, "Lock scheme Unknown or Corrupted" <br/>** 17581, "Trigger is disabled."<br/>** 17582, "Trigger is enabled."<br/>** 18571, "The attribute '%1!' is not applicable to tables with allpages lock scheme."<br/>*/</p><p>/*<br/>** IMPORTANT NOTE:<br/>** This stored procedure uses the built-in function object_id() in the<br/>** where clause of a select query. If you intend to change this query<br/>** or use the object_id() or db_id() builtin in this procedure, please read the<br/>** READ.ME file in the $DBMS/generic/sproc directory to ensure that the rules<br/>** pertaining to object-id's and db-id's outlined there, are followed.<br/>*/</p><p>create procedure sp_help<br/>@objname varchar(92) = NULL /* object name we're after */<br/>as</p><p>declare @typeid int /* type of object in systyp <br/>es */<br/>declare @sysstat smallint /* the type of the object */<br/>declare @OS_file varchar(255) /* physical file for ext tab */<br/>declare @msg varchar(250)<br/>declare @sptlang int<br/>declare @len1 int, @len2 int, @len3 int, @len4 int, @sysstat2 int<br/>declare @sqltex <br/>t varchar(255) /* SQL to execute using execute<br/> ** immediate. */</p><p>if @@trancount = 0<br/>begin<br/> set chained off<br/>end</p><p>set transaction isolation level 1</p><p>select @sptlang = @@langid</p><p>if @@langid != 0<br/>begin<br/> if not exists ( select * from master.dbo.sysmessages where error<br/> between 17100 and 17109 and langid = @@langid)<br/> select @sptlang = 0<br/>end</p><p>set nocount on<br/>略.</p>
页:
[1]