SQL Syntax Flashcards

1
Q

What does it mean? “SET ANSI_NULLS ON”

A

Handling Nulls:
Equality comparison: NULL value will be evaluated to UNKNOWN.
Inequality comparison: NULL value will result in UNKNOWN.
Aggregate functions: NULL values are ignored.

ANSI NULLS is ON by Default

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

What does “SET QUOTED_IDENTIFIER ON” mean?

A

String literals: Double quotation marks (“”) are used to enclose string literals.
Identifiers: Double quotation marks (“”) are used to enclose identifiers such as table names, column names, and aliases that contain special characters or reserved keywords.

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

Stored Procedure General Format

A

CREATE PROCEDURE Procedure_Name
@Parameter DATA_TYPE
AS
BEGIN
xxxxxxxxxxx
END
GO

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

What are the three types of Functions?

A

1-Inline (Table Value)
2-Multi Statement (Table Value)
3-Scalar

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

Inline Function General Format

A

CREATE FUNCTION Function_Name (@Parameter DATA_TYPE)
RETURNS TABLE
AS
RETURN
xxxxxxxxxxxxxx

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

Multi Statement Function General Format

A

CREATE FUNCTION Function_Name (@Parameter DATA_TYPE)
RETURNS Table_Name TABLE ([Column_Name] DATA_TYPE)
<@Table_Variable_Name, sysname, @Table_Var> TABLE
AS
BEGIN
xxxxxxxxxxxxxxxxxx
RETURN
END

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

Scalar Function General Format

A

CREATE FUNCTION Function_Name (@Parameter DATA_TYPE)
RETURNS DATA_TYPE
AS
BEGIN

DECLARE @Variable_Name DATA_TYPE
RETURN @Variable_Name

END

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

Create Database

A

CREATE DATABASE database_name;

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

Create Table

A

CREATE TABLE table_name (
ID INT IDENTITY PRIMARY KEY,
column_name_1 DATA_TYPE NOT NULL,
column_name_2 DATA_TYPE NULL,
);

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

Bulk Insert from CSV file

A

BULK INSERT Employees
FROM ‘file_address.csv’
WITH (
FIELDTERMINATOR = ‘,’,
ROWTERMINATOR = ‘\n’,
FIRSTROW = 2
);

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