SQL Common Code Snippets

Source: Internet
Author: User

--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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.