Final Study Topics Flashcards

1
Q

What are the 4 types of table expressions?

A

Derived Tables
CTE
View
Inline Table-Valued Functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 3 millisecond values that datetime can have without rounding?

A

0, 3, 7

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the only type of function that can be used and still be a SARG?

A

CAST(@DateVar as Date)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What datatypes can JSON elements contain?

A
String
Number
Boolean
object
array
null
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Where does WITH CHECK OPTION go within a View Creation Statement?

A

At the end of the statement:

Create view ViewName
as
Select * from table
with check option;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which function statement is more efficient?

A

Inline Table Value Function (MultiStatement Table Value Function is slower)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the steps needed to insert into an identity field on a table?

A

SET IDENTITY_INSERT ON;
INSERT INTO TABLE (IDENTITY) VALUES (VALUE)
SET IDENTITY_INSERT OFF;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can you get a the time in a different timezone when you have a datetime?

A

SWITCHOFFSET(DateTime AT TIME ZONE TimeZone, 0)

Examples of TimeZone are: ‘Pacific Standard Time’, ‘Eastern Standard Time’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the syntax for datefromparts?

A

DATEFROMPARTS(YEAR, MONTH, DAY, HOUR, MINUTES, SECONDS)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the EOMONTH function do? What is the syntax?

A

It gives the last day of the month passed to it:

EOMONTH(DateVar, MonthOffset)
IE: dateadd(day, 1, EOMONTH(sysdatetime(), -1)) gets the first day of the month

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the syntax for creating a temporal table?

A

CREATE TABLE dbo.TableName
(
[ValidFrom] datetime2 GENERATED ALWAYS AS ROW START
, [ValidTo] datetime2 GENERATED ALWAYS AS ROW END
, PERIOD FOR SYSTEM_TIME (ValidFrom, ValidTo)
)
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = dbo.TableHistory));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you query data from a temporal table?

A

SELECT * FROM dbo.TemporalTable
FOR SYSTEM_TIME
BETWEEN ‘2019-01-01 00:00:00.0000000’ AND ‘2020-01-01 00:00:00.0000000’
ORDER BY ValidFrom;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly