You are on page 1of 5

--2011/12/12

--

--'
--''('')
--ex. ShowIt's a book
go
Select 'It''s a book'
go
------------------------------------------------------
--+
--ex. 'A''B'
go
Select 'A' + 'B'
go
--ex. '1''2'
go
Select '1' + '2'

go
Select CAST(1 AS CHAR(1))
+ CAST(2 As CHAR(1))
go
------------------------------------------------------
--:SubString(string, start, length)
--length
--ex. ABANDON
go
Select SUBSTRING(val, 1, 2)
,SUBSTRING(val, 5, 8000)
,SUBSTRING(val, 5, LEN(val)+1)
From
(
Select 'ABANDON' val
) A
go
--:
----

Substringlength
int, 2

-----------------------------------------------------

--
--: Left(string, length)
-Right(string, length)
--length
--ex. ABANDON
go
Select Left('ABANDON', 2)
,SUBSTRING('ABANDON', 1, 2)
go
Select Right('ABANDON', 2)
go
-----------------------------------------------------

--
--:Charindex(set, string, [, start])
--start
--ex. ABANDON
go
Select CHARINDEX('O', 'ABONDON')
,CHARINDEX('O', 'ABONDON', 4)
go

------------------------------------------------------
--:LEN(string)
--
--ex. ABANDON
go
Select LEN('ABANDON')
,LEN('ABANDON ')
go
------------------------------------------------------
--:LTRIM(string)
-RTRIM(string)
--ex. ABANDON
go
Select LTRIM(' ABANDON ')
,RTRIM(' ABANDON ')
,RTRIM(LTRIM(' ABANDON '))
go
------------------------------------------------------

--:REPLACE(string, search_string,
replacement_string)
--ex. ABANDON
go
Select REPLACE('ABANDON', 'A', '#')
go

You might also like