-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05. Built-in functions.sql
53 lines (35 loc) · 1.03 KB
/
05. Built-in functions.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--Concatenation
SELECT CONCAT(FirstName, ' ', LastName) AS [Full Name]
FROM Employee
--CONCAT replaces NULL values with empty string
--With separator
SELECT CONCAT_WS(' ', FirstName, LastName) AS [Full Name]
FROM Employee
--Substring
SUBSTRING('SoftUni', 5, 3) --indexes start from 1
SELECT AtticleId, Author, Content,
SUBSTRING(Content, 1, 200) + '...' AS Summary
FROM Articles
--Replace
REPLACE('SoftUni', 'Soft', 'Hard')
SELECT
REPLACE('SoftUni', 'Soft', 'Hard') AS Title
FROM Articles
USE Demo
SELECT * FROM Customers
SELECT
CustomerID,
FirstName,
LastName,
LEFT(PaymentNumber, 6) + '**********'
FROM Customers
SELECT
CustomerID,
FirstName,
LastName,
CONCAT(LEFT(PaymentNumber, 6), REPLICATE('*', LEN(PaymentNumber) - 6)) AS PaymentNumber
FROM Customers
CHARINDEX(Pattern, String, [StartIndex]) -- Start from 1
STUFF(String, StartIndex, Length, Substring) -- Length is how many characters to delete
SELECT FORMAT(CAST('2019-01-21' AS DATE), 'D', 'bg-BG')
SELECT ABS(-90)