Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.
3.3.3. T-SQL Transformations (COPY, CTAS)
💡 First Principle: T-SQL provides set-based transformations optimized for relational data. CTAS (CREATE TABLE AS SELECT) combines table creation and population in a single, efficient operation.
CTAS (CREATE TABLE AS SELECT)
- Purpose: Create new table from query results
- Benefit: Combines creation and population in single operation
- Use Case: Materializing transformed data, creating summary tables
-- Create aggregated sales table using CTAS
CREATE TABLE dbo.MonthlySalesSummary AS
SELECT
YEAR(OrderDate) AS Year,
MONTH(OrderDate) AS Month,
Region,
SUM(SalesAmount) AS TotalSales,
COUNT(*) AS OrderCount
FROM dbo.FactSales
GROUP BY YEAR(OrderDate), MONTH(OrderDate), Region;
Enroll to unlock the 27 practice questions written for this section, so you can test what you just read while it is fresh.
Enroll to unlock the 9 flashcards for this section and review them on a spaced-repetition schedule.
Written byAlvin Varughese
Founder•20 professional certifications