CREATE Function Dbo.GetAge ( @birthday datetime, @now datetime ) Returns int As Begin Declare @Age int, @year int, @month int, @Day int Set @age = Set @year = Set @month = Set @day = Set @year = DatePart(Year,@Now) - DatePart(Year, @BirthDay) Set @mo
mark if exists (select * from dbo.sysobjects where id = object_id(N'UF_ETL_GetDistance') and xtype in (N'FN', N'IF', N'TF')) drop function UF_ETL_GetDistance GO CREATE FUNCTION UF_ETL_GetDistance ( ,), ,), ,), ,) ) ,) AS BEGIN ,) *PI())) END go
--@StartDate 本年度第一天 --@EndDate 本年度最后一天 , ) , DATEADD(yy, , , )) IF EXISTS ( SELECT * FROM tempdb..sysobjects WHERE id = OBJECT_ID('tempdb..#tb_work') ) BEGIN DROP TABLE #tb_work END CREATE TABLE #tb_work ( RN INT , WorkDate DATE ,--日期 DeWeek ) ,--星期几
/****** Script for SelectTopNRows command from SSMS ******/ SELECT [fdSequenceID] ,[fdInnerTime] ,[fdTime] ,[fdData] ,[fdState] ,[fdUpdateTime] ,[fdCreateTime] FROM [NewDBTest].[dbo].[tbDataMonthHG] WITH f AS ( SELECT ROW_NUMBER()OVER( partition by f
(1) SQL标记 连接连个表然后用 DATA COMPAREDATA进行区分select 'DATA ' ,'列名1','列名2','列名3' from 表 union select 'COMPAREDATA','列名1','列名2','列名3' from 表 (2) sqlserver计算时间差DATEDIFF 函数