Format: Tutorial + diagrams + project-based examples + practical tips
Introduction
For FullStack .NET developers, SQL Server is a critical skill because it powers the data layer of most enterprise applications. Understanding queries, joins, and stored procedures ensures efficient data handling and seamless integration with .NET applications.
At CuriosityTech, learners gain hands-on experience connecting SQL Server with ASP.NET Core and EF Core, learning best practices for real-world database operations.
1. Connecting .NET Applications to SQL Server
Using Entity Framework Core or ADO.NET, you can connect your .NET app to SQL Server.
EF Core Example:
optionsBuilder.UseSqlServer(“Server=.;Database=CuriosityTechDB;Trusted_Connection=True;”);
ADO.NET Example:
using(SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand cmd = new SqlCommand(“SELECT * FROM Courses”, conn);
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
Console.WriteLine(reader[“Name”]);
}
}
2. SQL Queries in Practice
Basic SELECT Query:
SELECT * FROM Courses;
SELECT Name, Instructor FROM Courses WHERE DurationInHours > 10;
INSERT Query:
INSERT INTO Courses (Name, Instructor, DurationInHours)
VALUES (‘Advanced C#’, ‘Bhavesh Barange’, 20);
UPDATE Query:
UPDATE Courses
SET DurationInHours = 25
WHERE Name = ‘Advanced C#’;
DELETE Query:
DELETE FROM Courses
WHERE Name = ‘Advanced C#’;
3. Understanding Joins
Joins allow combining data from multiple tables.
Types of Joins:
Join Type | Description | Example |
INNER JOIN | Returns records matching in both tables | Students INNER JOIN Enrollment ON Students.Id = Enrollment.StudentId |
LEFT JOIN | Returns all records from left table and matches from right | Students LEFT JOIN Enrollment … |
RIGHT JOIN | Returns all records from right table and matches from left | Courses RIGHT JOIN Enrollment … |
FULL OUTER JOIN | Returns all records from both tables | Students FULL OUTER JOIN Enrollment … |
Example:
SELECT s.Name, c.Name AS CourseName
FROM Students s
INNER JOIN Enrollment e ON s.Id = e.StudentId
INNER JOIN Courses c ON e.CourseId = c.Id;
Diagram:
[Students]—<Enrollment>—[Courses]
4. Stored Procedures
Stored procedures allow predefined SQL logic that can be reused and executed efficiently.
Creating a Stored Procedure:
CREATE PROCEDURE GetCourseByInstructor
@InstructorName NVARCHAR(50)
AS
BEGIN
SELECT * FROM Courses WHERE Instructor = @InstructorName;
END
Executing Stored Procedure in C#:
using(var context = new CuriosityTechContext())
{
var instructorCourses = context.Courses
.FromSqlRaw(“EXEC GetCourseByInstructor @p0”, “Bhavesh Barange”)
.ToList();
}
5. Real-World Project: CuriosityTech Learning Platform
Scenario: Build a course enrollment dashboard:
- Students table → stores learner information
- Courses table → stores available courses
- Enrollment table → stores student-course relationships
- Joins → to display enrolled courses per student
- Stored Procedures → fetch top-performing instructors or courses
ER Diagram:
[Students] —< [Enrollment] >— [Courses]
6. Best Practices
- Use parameterized queries to prevent SQL injection
- Normalize data to reduce redundancy
- Index frequently queried columns for performance
- Use stored procedures for complex queries and reusable logic
- Always test queries and procedures on a development database before production


9. CuriosityTech.in Mentorship Approach
- Hands-on exercises connecting ASP.NET Core + EF Core + SQL Server
- Real-world scenarios: Course portal, enrollment tracking, analytics dashboards
- Step-by-step guidance ensures learners understand both SQL and .NET integration
Conclusion
Mastering SQL Server is essential for .NET FullStack developers. From writing queries and joins to using stored procedures, you gain the ability to handle data efficiently and power dynamic applications. With CuriosityTech.in’s mentorship, learners develop both technical and practical skills, ready for professional projects.
The next step is Day 12 – Authentication & Authorization in ASP.NET Core Applications, where we’ll secure application