Exercises Flashcards

1
Q

Create a Computed Column in a table

A
CREATE TABLE #TEMPTBL (
     FIRSTNAME VARCHAR(50)
    ,LASTNAME VARCHAR(50)
    ,FULLNAME AS (FIRSTNAME + ' ' + LASTNAME) PERSISTED
)

ADD PERSISTED IF YOU WANT THE DATA ALWAYS THERE, OTHERWISE IT WILL ALWAYS BE COMPUTED

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

Alter an existing computed column in a table

A

You can’t. You have to drop the column and recreate it.

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

Create a FileGroup

A

ALTER DATABASE [DBNAME] ADD FILEGROUP [FILEGROUPNAME]

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

Add a file to a filegroup

A

USE MASTER
GO
ALTER DATABASE [DBNAME] ADD FILE (NAME N’FILENAME’, FILENAME = N’C:\PATH\FILENAME.NDF’, SIZE = 1000KB, FILEGROWTH = 600 KB ) TO FILEGROUP [FILEGROUP]

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

Create a calculated column

A
create table #calccol (
	firstname varchar(10)
	, lastname varchar (10)
        --Calculated Column
	, fullname as (firstname + ' ' + lastname) 
)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Create a calculated Column that becomes a permanent column

A
create table #calccol (
	firstname varchar(10)
	, lastname varchar (10)
        --Calculated Column - Persisted
	, fullname as (firstname + ' ' + lastname) PERSISTED
)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Create a Memory-Optimized Table

A

CREATE TABLE [TABLENAME] (
COL1 INT PRIMARY KEY NONCLUSTERED
, COL2 VARCHAR(5)
) WITH (MEMORY_OPTIMIZED = ON, DURABILITY=SCHEMA_AND_DATA)

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

Create a natively compiled stored procedure

A
CREATE PROCEDURE TestProc 
    @var1 int
    WITH NATIVE_COMPILATION
              , SCHEMABINDING
AS 
BEGIN ATOMIC
    WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N'us_english')
return @var1
END
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Create a clustered (or non clustered) columnstore index on a table

A

CREATE (NON)CLUSTERED COLUMNSTORE INDEX [INDEXNAME] ON [TABLENAME] WITH (DROP_EXISTING=OFF[ON], COMPRESSION_DELAY = 0) ON [FILEGROUP]

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

Create a table that has a sparse column

A

CREATE TABLE [TABLENAME] (
FIRSTNAME VARCHAR(50)
.MIDDLENAME VARCHAR(50) SPARSE NULL
)

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

Create CLR Stored Procedure

A

CREATE PROCEDURE dbo.CLRTest

as external name CLRTest.StoredProcedures.SqlStoredProcedure1

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

Create CLR Assembly

A

CREATE ASSEMBLY CLRTest FROM N’C:\FILEPATH\Assembly.dll’ WITH PERMISSION_SET = [SAFE,UNSAFE,EXTERNAL_ACCESS]

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