--=============================== ============================
-- ,
select stuff('hello,world!',4,4,'****') -- hel****orld!
--
select substring('Hello,World!',2,10) -- ello,World
--
select replace('hello,world!','ll','aa') -- heaao,world!
--
select ltrim(' hello,world!') -- hello,world!
--
select ltrim('hello,world! ') -- hello,world!
--
select ltrim(' hello,world! ') -- hello,world!
-- NULL
select isnull('a',null) -- a
--
select cast('2007-10-11' as datetime) -- 2007-10-11 00:00:00.000
select convert(datetime,'2007-10-11') -- 2007-10-11 00:00:00.000
--
select len('hello,world!') -- 12
-- 3
select left('hello,world!',3) -- hel
-- 3
select right('hello,world!',3) -- ld!
-- 3
select right('hello,world!',(len('hello,world!')-3)) -- lo,world!
-- 3
select left('hello,world!',(len('hello,world!')-3)) -- hello,wor
-- ( )
select charindex('e','hello,world!') -- 2
-- 2 4
select left(right('[ ]aaa',len('[ ]aaa')-1),4) --
--
select lower('HELLO,WORLD!') -- hello,world!
--
select UPPER('hello,world!') -- HELLO,WORLD!
--
( nvarchar , nvarchar; varchar。 NULL, NULL。)
SELECT REPLACE('Hello,World!','l','a') -- Heaao,Worad!
SELECT REPLACE('Hello,World!','l','') -- Heo,Word!
SELECT REPLACE('Hello,World!','l',null) -- NULL
--
select REPLICATE('Hello,World!',4) -- Hello,World!Hello,World!Hello,World!Hello,World!
--
select REVERSE('Hello,World!') -- !dlroW,olleH
-- DIFFERENCE , ( ), ( 0-4 )
DIFFERENCE('sun','san') -- 4
DIFFERENCE('sun','safdsdf') -- 3
DIFFERENCE('sun','dgffgfdg') -- 0
--
SELECT STR(123.34584, 7, 3) -- 123.346
-- , *
SELECT STR(123333.34584, 5, 4) -- *****
--===================================================================================
--===================================== ==================================
--
select floor(123456.1234) -- 123456
-- 。 ,
select ceiling(123.010) -- 124
select ceiling(null) -- NULL
--
select round(126.018,2) -- 126.12
-- 0-1 FLoat
select rand() -- 0.94170703697981
-- PI
SELECT PI() -- 3.14159265358979
--===================================================================================