These functions in fact, many online data, but in order to facilitate their own memory, I still decided to write a bit, all say good memory than bad writing, so or write a bit more.
The cast () function essentially converts one type to another, such as converting a string type to a time type: SELECT CAST (' 2011-10-2 ' as datetime), or convert the numeric type to a string type: SELECT CAST (1 as BIGINT)
The CONVERT () function is mainly used to display date/time data in different formats: convert (data_type (length),data_to_be_converted,style )
data_type (length) Specifies the target data type (with optional lengths),
The data_to_be_converted contains values that need to be converted,
style Specifies the date/time output format (specific reference: http://www.w3school.com.cn/sql/func_convert.asp)
Example: CONVERT (VARCHAR), GETDATE () results: Dec 11:45 PM
CONVERT (VARCHAR), GETDATE (), 110) Results: 12-29-2008
The DATEPART () function is primarily used to return a separate part of a date/time, such as year, month, day, hour, minute, and so on: DatePart (datepart,date)
The date parameter is a valid day expression. datepart the part to be removed (see also: http://www.w3school.com.cn/sql/func_datepart.asp)
For example: Select DATEPART (YYYY, ' 2011-10-1 ') the part that is removed is: 2011
Left returns the specified number of characters that begin at the beginning of the string. Right returns the specified number of characters starting at the left of the string.
Example: Select Left (' name ', 2); Result: NA
Select Right (' name ', 2) Result: Me
The use of these three functions in SQL Server Cast,convert,datepart,left,right