Home
Babin Joshi
Cancel

Basic Date From Parts

Dates from parts DATEFROMPARTS(year,month,day) TIMEFROMPARTS(hour, minute, second, fraction, precision) DATETIMEFROMPARTS(year, month, day, hour, minute, seconds,ms) ...

Building Dates

Building Dates Building a Date SELECT GETDATE() AS DateTime_LTz, GETUTCDATE() AS DateTime_UTC; SELECT SYSDATETIME() AS DateTime2_LTz,...

Window Functions

Grouping data in T-SQL SELECT SalesPerson, SalesYear, CurrentQuota, ModifiedDate FROM SaleGoal WHERE SalesYear = 2011 ...

Loops

Using Variables in T-SQL Variables are needed to set values DECLARE @variablename data_type Must start with the character @ Vari...

Counts and Totals

Examining Totals with Counts SELECT COUNT(*) FROM Incidents The above sql statments returns the total number of rows in the Incidents table. Count w...

Intermediate To SQL Server

Exploring Data With Aggregation Reviewing summarized values for each column is a common first step in analyzing data If the data exists in a database, fastest way to aggreg...

Model 1:N relationships with foreign keys

Implementing relationships with Foreign Keys A Foreign Key (FK) points to the Primary key (PK) of another table. Domain of FK must be equal to the domain of PK Each v...

Keys and Superkeys

What is a Key? Attribute(s) that idenfity a record uniquely As long as attributes can be removed: superkey If no more attributes can be removed: minimal superky or ke...

Constraints

Integrity Constraints Attribute Constraints, e.g data types on columns Key Constraints, e.g primary keys Referential Integrity Constraints, enforced through foreign k...

Relational Databases

Using information schema SELECT table_schema, table_name FROM information_schema.tables; Taking the look at the columns of a ...