程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SqlServer數據庫 >> 關於SqlServer >> 編寫存儲過程常用技巧匯總

編寫存儲過程常用技巧匯總

編輯:關於SqlServer
 

-- 根據存儲過程名取存儲過程內容


--  調試 GetContentByProcedureName '[dbo].[CPP_CountOfTrdeByUserID]'
alter procedure GetContentByProcedureName
( @ProcedureName nvarchar ( 500 ))
as

if exists ( select * from dbo.syscomments where id = object_id (N'' + @ProcedureName+ '' ))
select c. text , c.encrypted, c. number , xtype = convert ( nchar ( 2 ), o.xtype),
datalength (c. text ), convert ( varbinary ( 8000 ), c. text ), 0 from dbo.syscomments c, dbo.sysobjects o
where o.id = c.id and c.id = object_id (N'' + @ProcedureName + '' )
order by c. number , c.colid option (robust plan )


存儲過程總top+變量參數

 

Alter proc getWorkPlan2
(
@intCounter int
, @lngUserID int
)
as
set rowcount @intCounter
select lngWorkID,strWorkName,strExecHumanName,strBeginDate
from worklist where lngExecHumanID = @lngUserID
order by lngWorkID desc

 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved