PS: essays written to use in SQL Server (duplicate, replace, intercept, to space, to the number of digits after the decimal point)
/*---------------------------repeat-------------------- ------------ * / - {return repeated string abc # abc # abc #] SELECT replicate ( 'ABC #',. 3); / * --------- ------------------replace------------------------------- - * / - e replacement string will be replaced by E [return] abcEdEf --replace ( 'string', 'text before replacement', 'text after replacement') SELECT replace ( 'abcedef', 'e' , 'E'); - the replacement string specified location heABCworld [Back] --stuff ( 'string', where replacement starts, alternatively several, 'character to replace') SELECT Stuff ( 'Hello World', . 3,. 4, 'the ABC'); / * ---------------------------- taken ---------- ---------------------- * / - intercepting the returned string [a, ab, Wrold] --subString ( 'string', taken where to start , taken several) SELECT subString ( 'ABC',. 1,. 1), subString ( 'ABC',. 1, 2), subString ( 'Hello Wrold',. 7,. 5); - Take the left return string [left, leftStr] --left ( 'string', taken from the left several) left SELECT ( 'LeftString',. 4); SELECT left ( 'LeftString',. 7); - the right to take the returned string [String, ing] --right ( 'string', starts from the right to take a few) SELECT right ( 'LeftString',. 6); SELECT right ( 'LeftString',. 3); / * --------------------------- go blank - --------------------------------- * / - to remove the spaces left select ltrim ( 'abc'), ltrim ( 'ABC # #'), LTRIM ( 'ABC'); - the right to remove the spaces SELECT RTRIM ( 'ABC'), RTRIM ( 'ABC # #'), RTRIM ( 'ABC'); / * ----- -------------------- ------------------------ go after the decimal point ---- * / - with the function ROUND (numeric, s), where s denotes the number of decimal places SELECT ROUND (4.994,2) - returns 4.990 - a function CAST (values as numeric (n, s)) , wherein n represents the number of significant digits, s represents decimal SELECT CAST (4.994 as numeric (10,2 )) - 4 search returns.99 - a function CONVERT (numeric (n, s) , value), where n represents the number of significant digits, s represents the number of decimal places SELECT CONVERT (numeric (10,2), 4.9852222) - Returns 4.99