SQL Server Flashcards

1
Q

What is a stored procedure and how do you make one?

A

A stored procedure is a saved SQL query that it can be reused. Can add parameters using @ symbol.

CREATE PROCEDURE procedure_name
AS sql_statement
GO

CREATE PROCEDURE procedure_name @param type
AS sql_statement
GO

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

How do you execute a stored procedure?

A

EXEC procedure_name

EXEC procedure_name @parm = parameter

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

How do you create a new database?

A

CREATE DATABASE databasename

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

How to create a table?

A
CREATE TABLE tableName (
ID int IDENTITY(1,1) PRIMARY KEY
		Column1 datatype,
		Column2 datatype,
		Column3 datatype
		OtherID int FOREIGN KEY REFERENCES OtherTable(ID)
)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a composite key?

A

A composite key is a key created by combining two columns

It can be used as a primary key if it is unique

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