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. 最短路【洛谷P3393】 逃离僵尸岛

    P3393 逃离僵尸岛 题目描述 小a住的国家被僵尸侵略了!小a打算逃离到该国唯一的国际空港逃出这个国家. 该国有N个城市,城市之间有道路相连.一共有M条双向道路.保证没有自环和重边. K个城市已经被 ...

  2. Docker部署MySql应用

    1. MySQL部署 1.1拉取MySQL镜像 docker pull mysql 查看镜像 docker images 1.2创建MySQL容器 docker run -di --name piny ...

  3. 数据结构28:广义表及M元多项式

    广义表,又称为列表.记作: LS = (a1,a2,…,an) ;( LS 为广义表的名称, an 表示广义表中的数据). 广义表可以看作是线性表的推广.两者区别是:线性表中的数据元素只能表示单个数据 ...

  4. [POI2014]KUR-Couriers BZOJ3524 主席树

    给一个长度为n的序列a.1≤a[i]≤n. m组询问,每次询问一个区间[l,r],是否存在一个数在[l,r]中出现的次数大于(r-l+1)/2.如果存在,输出这个数,否则输出0. Input 第一行两 ...

  5. DRAM与SRAM

    传送门:https://www.cnblogs.com/nano94/p/4014082.html 关于内存的补充知识传送门:https://blog.csdn.net/Hello_Sue/artic ...

  6. pytorch实现squeezenet

    squeezenet是16年发布的一款轻量级网络模型,模型很小,只有4.8M,可用于移动设备,嵌入式设备. 关于squeezenet的原理可自行阅读论文或查找博客,这里主要解读下pytorch对squ ...

  7. CMD 有关知识点

    java的Runtime.getRuntime().exec(commandStr)可以调用执行cmd指令. cmd /c dir 是执行完dir命令后关闭命令窗口. cmd /k dir 是执行完d ...

  8. apache 压缩 gzip

    配置 编辑httpd.conf文件 去掉 #LoadModule headers_module modules/mod_headers.so 前面的注释# 去掉 #LoadModule deflate ...

  9. 数据结构4.3_字符串模式匹配——KMP算法详解

    next数组表示字符串前后缀匹配的最大长度.是KMP算法的精髓所在.可以起到决定模式字符串右移多少长度以达到跳跃式匹配的高效模式. 以下是对next数组的解释: 如何求next数组: 相关链接:按顺序 ...

  10. Avito Cool Challenge 2018:D. Maximum Distance

    D. Maximum Distance 题目链接:https://codeforces.com/contest/1081/problem/D 题意: 给出一个连通图以及一些特殊点,现在定义cost(u ...