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. node 后台搭建笔记

    *注:本文是个人记录,非常粗略 1.建立server服务的文件被单独放置在一个文件夹下或最外层 2.src文件包含:controller/model/routes 文件夹 和 app.js文件

  2. angularJs获取复选框中id 进行批量删除

    主要思路:我们需要定义一个用于存储选中 ID 的数组,当我们点击复选框后判断是选择还是取消选择,如果是选择就加到数组中,如果是取消选择就从数组中移除.在点击删除按钮时需要用到这个存储了 ID 的数组. ...

  3. react todolist代码优化

    Todolist.js import React, { Component,Fragment } from 'react'; import TodoItem from './TodoItem'; im ...

  4. pycharm、idea 2018软件安装教程

    Python3.7安装: https://www.jb51.net/article/146326.htm pycharm软件: https://www.jianshu.com/p/cf77d74bef ...

  5. hdu1430 魔板(康拓展开 bfs预处理)

    魔板 Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...

  6. Codeforces - 625B 贪心

    求最小不重复匹配次数 改最后一个字符最划算 我当时怎么就没看出来.. #include<bits/stdc++.h> using namespace std; string S,T; in ...

  7. hdu3746 KMP-next数组的应用

    Cyclic Nacklace Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  8. web服务器Nginx环境下如何实现安全证书https的配置

    https跟http的关系 https没出现之前,我们网站大多数都是http开头,http全名超文本传输协议,客户端据此获取服务器上的超文本内容.超文本内容则以HTML为主,客户端拿到HTML内容后可 ...

  9. js input复选框选中父级同时子级也选中

    js实现复选框选中父级元素子级元素也选中,没有子级元素选中父级也不选中的效果 HTML <tr> <td> <label> <input name=" ...

  10. RobotFramework AppiumLibrary 用户关键字

    RobotFramework AppiumLibrary 用户关键字 最近在用robotframework搞安卓app 的自动化,其中用到了 AppiumLlibrary 的关键字,我都映射成了用户关 ...