--the STUFF function inserts a string into another string. It removes the specified length of characters from the starting position in the first string, and then inserts the second string at the beginning of the first string. STUFF(character_expression, start, length, character_expression)--The following example removes the three characters from the 2nd position (character B) in the first string abcdef, and then inserts a second string at the beginning of the deletion, creating and returning a string. SELECT STUFF('abcdef',2,3,'IJKLMN');GO--calculates the difference of two time by the hour, the result is accurate to the minuteSELECT ROUND((DATEDIFF(Minute,'2014/1/3 18:40:00','2014/1/3 20:00:00') ) / CONVERT(FLOAT, -),1) asdiffdate--Floor returns the largest integer less than or equal to the specified numeric expression Floor(123.56)--123--ceiling returns the smallest integer greater than or equal to the specified numeric expression. CEILING(123.26)--124--Time IncreaseDateAdd(Week,1,'2014/1/3')--SQL Server field typeNumeric (Ten,2) refers to a field that is a numeric type with a length of 10 decimals of two bits.--get the next morning timeSELECT DATEADD( Day,DATEDIFF( Day,-1,GETDATE()),0)
SQL Common Code Snippets