-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelect_and_Insert_Into.sql
More file actions
43 lines (24 loc) · 1.22 KB
/
Select_and_Insert_Into.sql
File metadata and controls
43 lines (24 loc) · 1.22 KB
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
---TO DO from Previous Video---
---Using the [AdventureWorks2019].[Person].[Address] table, Concat the following columns with a comma and space separator and return one column as Full Address
--[AddressLine1], [AddressLine2], [City], [PostalCode]
SELECT CONCAT_WS(', ', [AddressLine1], [AddressLine2], [City], [PostalCode]) as [Full Address]
FROM [AdventureWorks2019].[Person].[Address]
---1---
---SELECT INTO
---Select * Into NEWTable from ExistingTable
select FirstName, MiddleName, LastName, CONCAT_WS(' ', FirstName, MiddleName, LastName) FullName
Into dbo.People
from [AdventureWorks2019].Person.Person
select FirstName, MiddleName, LastName, CONCAT_WS(' ', FirstName, MiddleName, LastName) FullName
Into dbo.Person
from [AdventureWorks2019].Person.Person
where BusinessEntityID = 0
---2---
---INSERT INTO
---Insert Into NEWTable Select * from ExistingTable
Insert into [dbo].[Person]
select FirstName, MiddleName, LastName, CONCAT_WS(' ', FirstName, MiddleName, LastName) FullName
from [AdventureWorks2019].Person.Person
---TO DO---
--CREATE A NEW TABLE Called Employee in your TESTDB with Just the ID, JobTitle and Hiredate
Select * FROM [AdventureWorks2019].HumanResources.Employee