Get ready for your next interview with our comprehensive question library
SQL Server is a relational database management system (RDBMS) developed by Microsoft. Its main components include:
SQL Server data types are categorized into:
Numeric Types: INT, BIGINT, SMALLINT, TINYINT, DECIMAL, NUMERIC, FLOAT, REAL, MONEY
String Types: VARCHAR, NVARCHAR, CHAR, NCHAR, TEXT, NTEXT
Date/Time Types: DATE, TIME, DATETIME, DATETIME2, SMALLDATETIME, DATETIMEOFFSET
Binary Types: BINARY, VARBINARY, IMAGE
Other Types: BIT, UNIQUEIDENTIFIER, XML, JSON (SQL Server 2016+)
Example:
CREATE TABLE Employee (
ID INT,
Name NVARCHAR(50),
Salary DECIMAL(10,2),
HireDate DATETIME
);
VARCHAR is suitable for English text, while NVARCHAR supports international characters and multiple languages. NVARCHAR requires more storage but provides better internationalization support.
Example:
-- INNER JOIN
SELECT e.Name, d.DepartmentName
FROM Employees e
INNER JOIN Departments d ON e.DeptID = d.ID;
PRIMARY KEY: Uniquely identifies each record in a table. Cannot be NULL and must be unique.
FOREIGN KEY: Links two tables together, referencing the primary key of another table.
Example:
CREATE TABLE Departments (
ID INT PRIMARY KEY,
Name NVARCHAR(50)
);
CREATE TABLE Employees (
ID INT PRIMARY KEY,
Name NVARCHAR(50),
DeptID INT FOREIGN KEY REFERENCES Departments(ID)
);
Upgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumUpgrade to Premium to see the answer
Upgrade to PremiumAccess all premium content - interview questions, and other learning resources
We regularly update our features and content, to ensure you get the most relevant and updated premium content.
1000 monthly credits
Cancel anytime