Anything can be programmable with defined syntax and common lib.

 ALTER PROCEDURE [dbo].[sp_GetLaborHourPerDayEmployee](@au_Date DATETIME, @au_employeeID VARCHAR(30))
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @au_ItemDate DATETIME; SET @au_ItemDate = CONVERT(VARCHAR(10), @au_Date, 120); SELECT SUM(ISNULL(T1.Hours,0)) as Hours
FROM [dbo].[LBS_Maintenance] as T0
left join [dbo].[LBS_LaborHour] as T1
on T0.MaintenanceID = T1.MaintenanceID
where T0.IsFlag = 0
and CONVERT(VARCHAR(10),T0.ItemDate,120) = @au_ItemDate
and T0.EmployeeID = @au_employeeID
--and (T2.CurrentStatus = 'Active' or (T2.CurrentStatus = 'Suspend' and T2.SuspendWhat = 'Billing'))
END
 USE [OES_LBS]
GO
/****** Object: UserDefinedFunction [dbo].[fn_GetLaborHourPerDayEmployee] Script Date: 08/07/2013 16:17:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER FUNCTION [dbo].[fn_GetLaborHourPerDayEmployee](@au_Date DATETIME, @au_employeeID VARCHAR(30))
RETURNS NUMERIC(5,2)
AS
BEGIN
DECLARE @ret NUMERIC(5,2)
SET @ret = 0
SELECT @ret = A0.Hours
FROM
(
SELECT SUM(ISNULL(T1.Hours,0)) as Hours
FROM [dbo].[LBS_Maintenance] as T0
left join [dbo].[LBS_LaborHour] as T1
on T0.MaintenanceID = T1.MaintenanceID
where IsFlag = 0
and T0.ItemDate = @au_Date
and T0.EmployeeID = @au_employeeID
--and (T2.CurrentStatus = 'Active' or (T2.CurrentStatus = 'Suspend' and T2.SuspendWhat = 'Billing'))
--and T1.Hours != 0
)as A0
RETURN(@ret)
END

SQL Stored Procedure and Function的更多相关文章

  1. Difference between Stored Procedure and Function in SQL Server

    Stored Procedures are pre-compile objects which are compiled for first time and its compiled format ...

  2. [转]Dynamic SQL & Stored Procedure Usage in T-SQL

    转自:http://www.sqlusa.com/bestpractices/training/scripts/dynamicsql/ Dynamic SQL & Stored Procedu ...

  3. SQL Server 在多个数据库中创建同一个存储过程(Create Same Stored Procedure in All Databases)

    一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 遇到的问题(Problems) 实现代码(SQL Codes) 方法一:拼接SQL: 方法二: ...

  4. SQL Server——存储过程(Stored Procedure)、事物、触发器

    存储过程(proc 或 procedure) 存储过程(Stored Procedure),计算机用语,是一组为了完成特定功能的SQL语句集,是利用SQL Server所提供的Transact-SQL ...

  5. java当中JDBC当中请给出一个sql server的stored procedure例子

    3.sql server的stored procedure例子: import java.sql.*;public class StoredProc0 {public static void main ...

  6. Modify a Stored Procedure using SQL Server Management Studio

    In Object Explorer, connect to an instance of Database Engine and then expand that instance. Expand  ...

  7. [转]Easy Stored Procedure Output Oracle Select

    本文转自:http://www.oraclealchemist.com/oracle/easy-stored-procedure-output/ I answered a question on a ...

  8. Entity Framework Tutorial Basics(29):Stored Procedure in Entity Framework

    Stored Procedure in Entity Framework: Entity Framework has the ability to automatically build native ...

  9. Stored Procedure 里的 WITH RECOMPILE 到底是干麻的?

    在 SQL Server 创建或修改「存储过程(stored procedure)」时,可加上 WITH RECOMPILE 选项,但多数文档或书籍都写得语焉不详,或只解释为「每次执行此存储过程时,都 ...

随机推荐

  1. 打谷机 BZOJ 1603 模拟

    Farmer John有一个过时的打谷机(收割小麦),它需要带子来带动.发动机驱动轮1总是顺时针旋转的,用来带动转轮2,转轮2来带动转轮3,等等.一共有n(2<=n<=1000)个转轮(n ...

  2. pycharm加开头注释

    选择 File and Code Templates -> Files -> Python Script #!/usr/bin/env python # encoding: utf-8 ' ...

  3. 记录下自己安装cuda以及cudnn

    之前已经装过一次了,不过没有做记录,现在又要翻一堆博客安装,长点记性,自己记录下. 环境 ubuntu16.04 python2.7 商家送过来时候已经装好了显卡驱动,所以省去了一大麻烦. 剩下的就是 ...

  4. Liunx 发送邮件

    可以使用rpm -qa | grep mailx查看系统自带的mailx版本. 使用wget http://sourceforge.net/projects/heirloom/files/latest ...

  5. [Leetcode]015. 3Sum

    public class Solution { public List<List<Integer>> threeSum(int[] num) { Arrays.sort(num ...

  6. CSS+jQuery实现轮播

    CSS+jQuery实现轮播 CSS jQuery 前端  实现功能: 自动轮播: 鼠标放在上面停止轮播: 鼠标放在上面显示左右切换的按钮: 鼠标放在小圆圈上显示对应的图片: 轮播效果图 style. ...

  7. Go语言基础之13--线程安全及互斥锁和读写锁

    一.线程安全介绍 1.1 现实例子 A. 多个goroutine同时操作一个资源,这个资源又叫临界区 B. 现实生活中的十字路口,通过红路灯实现线程安全 C. 火车上的厕所(进去之后先加锁,在上厕所, ...

  8. 【ACM】三点顺序

    三点顺序 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 现在给你不共线的三个点A,B,C的坐标,它们一定能组成一个三角形,现在让你判断A,B,C是顺时针给出的还是逆 ...

  9. 转 windows下安装pycharm并连接Linux的python环境 以及 windows 下notepad ++编辑 linux 的文件

    ######sample 1:windows下安装pycharm并连接Linux的python环境 https://www.cnblogs.com/junxun/p/8287998.html wind ...

  10. 转 PyCharm 进行调试 以及怎么熟悉一个已经成熟的项目的代码和断点 以及 jetBrains pycharm快捷键

    https://blog.csdn.net/guider2334/rss/list Ctrl + Q 现实document视图,查看选择元素的详细信息        (重要) Ctrl + Alt + ...