还想看看人们的存储过程/功能等注释标题是什么样的(所以发布你的例子)......我只是真正看到了SQL Server Management Studio创建的内容,但我对其他人看起来感兴趣...格式,使用的字符,程序信息/细节等我猜是真正让他们与众不同的......
SQL Server Management Studio(版本9)存储过程注释标头默认值:
-- =============================================
-- Author: Name
-- Create date:
-- Description:
-- =============================================
Run Code Online (Sandbox Code Playgroud)
Hag*_*i L 44
/******************************
** File:
** Name:
** Desc:
** Auth:
** Date:
**************************
** Change History
**************************
** PR Date Author Description
** -- -------- ------- ------------------------------------
** 1 01/10/2008 Dan added inner join
*******************************/
Run Code Online (Sandbox Code Playgroud)
Con*_*ict 19
--
-- STORED PROCEDURE
-- Name of stored procedure.
--
-- DESCRIPTION
-- Business description of the stored procedure's functionality.
--
-- PARAMETERS
-- @InputParameter1
-- * Description of @InputParameter1 and how it is used.
--
-- RETURN VALUE
-- 0 - No Error.
-- -1000 - Description of cause of non-zero return value.
--
-- PROGRAMMING NOTES
-- Gotchas and other notes for your fellow programmer.
--
-- CHANGE HISTORY
-- 05 May 2009 - Who
-- * More comprehensive description of the change than that included with the
-- source code commit message.
--
Run Code Online (Sandbox Code Playgroud)
Kul*_*MCA 10
我们使用这样的东西,对我来说非常有用.
/*
Description:
Author:
Create Date:
Param:
Return:
Modified Date:
Modification:
*/
Run Code Online (Sandbox Code Playgroud)
小智 8
-------------------------------------------------------------------------------
-- Author name
-- Created date
-- Purpose description of the business/technical purpose
-- using multiple lines as needed
-- Copyright © yyyy, Company Name, All Rights Reserved
-------------------------------------------------------------------------------
-- Modification History
--
-- 01/01/0000 developer full name
-- A comprehensive description of the changes. The description may use as
-- many lines as needed.
-------------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
我知道这篇文章很古老,但是格式正确的代码永远不会过时。
我将所有程序都使用此模板。有些人不喜欢冗长的代码和注释,但是由于某些人经常需要更新自90年代中期以来未曾涉及的存储过程,因此我可以告诉您编写格式良好且注释严重的代码的价值。编写的内容尽可能简明扼要,有时可能需要几天的时间才能掌握该过程的意图。只需阅读即可很容易地看到代码块在做什么,但要难得多(有时甚至是不可能)是在没有适当注释的情况下理解代码的意图。
向您解释它,就像您正在经历初级开发人员一样。假设阅读它的人对它要解决的功能领域一无所知,并且对SQL的了解有限。为什么?很多时候,即使他们无意或不愿意对其进行修改,人们也必须查看程序以理解它们。
/***************************************************************************************************
Procedure: dbo.usp_DoSomeStuff
Create Date: 2018-01-25
Author: Joe Expert
Description: Verbose description of what the query does goes here. Be specific and don't be
afraid to say too much. More is better, than less, every single time. Think about
"what, when, where, how and why" when authoring a description.
Call by: [schema.usp_ProcThatCallsThis]
[Application Name]
[Job]
[PLC/Interface]
Affected table(s): [schema.TableModifiedByProc1]
[schema.TableModifiedByProc2]
Used By: Functional Area this is use in, for example, Payroll, Accounting, Finance
Parameter(s): @param1 - description and usage
@param2 - description and usage
Usage: EXEC dbo.usp_DoSomeStuff
@param1 = 1,
@param2 = 3,
@param3 = 2
Additional notes or caveats about this object, like where is can and cannot be run, or
gotchas to watch for when using it.
****************************************************************************************************
SUMMARY OF CHANGES
Date(yyyy-mm-dd) Author Comments
------------------- ------------------- ------------------------------------------------------------
2012-04-27 John Usdaworkhur Move Z <-> X was done in a single step. Warehouse does not
allow this. Converted to two step process.
Z <-> 7 <-> X
1) move class Z to class 7
2) move class 7 to class X
2018-03-22 Maan Widaplan General formatting and added header information.
2018-03-22 Maan Widaplan Added logic to automatically Move G <-> H after 12 months.
***************************************************************************************************/
Run Code Online (Sandbox Code Playgroud)
除了此标头之外,您的代码还应经过注释,并从上到下概述。向主要功能部分添加注释块,例如:
/***********************************
** Process all new Inventory records
** Verify quantities and mark as
** available to ship.
************************************/
Run Code Online (Sandbox Code Playgroud)
添加许多内联注释,解释除最基本条件外的所有条件,并始终设置代码格式以提高可读性。缩进代码的垂直长页面比宽而短的页面好,并且在其他人支持您的代码的情况下,更容易查看代码块的开始位置和结束时间。有时,宽大的,非缩进的代码更具可读性。如果是这样,请仅在必要时使用它。
UPDATE Pallets
SET class_code = 'X'
WHERE
AND class_code != 'D'
AND class_code = 'Z'
AND historical = 'N'
AND quantity > 0
AND GETDATE() > DATEADD(minute, 30, creation_date)
AND pallet_id IN ( -- Only update pallets that we've created an Adjustment record for
SELECT Adjust_ID
FROM Adjustments
WHERE
AdjustmentStatus = 0
AND RecID > @MaxAdjNumber
Run Code Online (Sandbox Code Playgroud)
-- [why did we write this?]
-- [auto-generated change control info]
Run Code Online (Sandbox Code Playgroud)
小智 5
set timing on <br>
set linesize 180<br>
spool template.log
/*<br>
##########################################################################<br>
-- Name : Template.sql<br>
-- Date : (sysdate) <br>
-- Author : Duncan van der Zalm - dvdzalm<br>
-- Company : stanDaarD-Z.nl<br>
-- Purpose : <br>
-- Usage sqlplus <br>
-- Impact :<br>
-- Required grants : sel on A, upd on B, drop on C<br>
-- Called by : some other process<br
##########################################################################<br>
-- ver user date change <br>
-- 1.0 DDZ 20110622 initial<br>
##########################################################################<br>
*/<br>
sho user<br>
select name from v$database;
select to_char(sysdate, 'Day DD Month yyyy HH24:MI:SS') "Start time"
from dual
;
-- script
select to_char(sysdate, 'Day DD Month yyyy HH24:MI:SS') "End time"
from dual
;
spool off
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
87987 次 |
最近记录: |