Saturday, February 22, 2025

TOP 20 SQL interview questions for 2025

 






TOP 20 SQL interview questions for 2025

Hey Candidates here are the Top 20 SQL, that will help you crack the SQL interview

1. What is SQL?

SQL (Structured Query Language) is a standard language for accessing and manipulating databases. It is used for querying, updating, and managing data stored in a relational database.

2. What are the differences between SQL and MySQL?

  • SQL is a standard language for accessing and manipulating databases, while MySQL is a relational database management system (RDBMS) that uses SQL as its standard database language.
  • SQL is a query language, and MySQL is software for managing databases.
  • SQL commands are used in various database systems, whereas MySQL is a specific implementation of an RDBMS.
3. What are DDL and DML commands? Give examples.
  • DDL (Data Definition Language) commands are used to define the database structure. Examples include CREATE, ALTER, and DROP.
  • DML (Data Manipulation Language) commands are used for managing data within the database. Examples include SELECT, INSERT, UPDATE, and DELETE.
4. Write a query to retrieve all records from a table.

SELECT * FROM table_name;
5. How do you Join 2 tables
Tables can be joined using various types of joins, such as INNER JOIN, LEFT JOIN, RIGHT JOIN, 
and FULL JOIN. Here's an example using INNER JOIN:
SELECT *
FROM table1
INNER JOIN table2 ON table1.common_column = table2.common_column;
6. What is the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN?
  • INNER JOIN returns records that have matching values in both tables.
  • LEFT JOIN returns all records from the left table and matched records from the right table. If no match, NULL values are returned for columns of the right table.
  • RIGHT JOIN returns all records from the right table and matched records from the left table. If no match, NULL values are returned for columns of the left table.
  • FULL JOIN returns all records when there is a match in either left or right table. If there is no match, the result is NULL from the side where there is no match.
7. Explain the concept of normalization. 
Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity. It involves dividing large tables into smaller tables and defining relationships between them. Common forms of normalization are 1NF, 2NF, 3NF, and BCNF.

8. What is indexing? How does it improve query performance? 
Indexing involves creating a data structure (index) that improves the speed of data retrieval operations on a database table. Indexes provide a quick lookup for matching rows in a table based on indexed columns, thus reducing the time required for data access.

9. Write a query to find the second highest salary from an Employee table.
SELECT MAX(salary) AS SecondHighestSalary
FROM Employee
WHERE salary < (SELECT MAX(salary) FROM Employee);
10. What is a primary key and a foreign key?
A primary key is a column (or a combination of columns) that uniquely identifies each row in a table.
A foreign key is a column (or a combination of columns) that establishes a relationship between two 
tables by referencing the primary key of another table.
11. Explain the difference between DELETE and TRUNCATE.
DELETE is a DML command used to delete specific rows from a table based on a condition.
 It can be rolled back.
TRUNCATE is a DDL command used to remove all rows from a table, resetting it to an empty state. 
It cannot be rolled back and is faster than DELETE.
12. What is a subquery? Provide an example.
A subquery is a query within another query. It is used to return data that will be used in the main query 
as a condition.
SELECT employee_name FROM employees WHERE department_id = (SELECT department_id FROM departments
WHERE department_name = 'Sales');

13. How do you handle transactions in SQL?

Transactions are handled using the following commands:

  • BEGIN TRANSACTION: Starts a transaction.

  • COMMIT: Saves all changes made during the transaction.

  • ROLLBACK: Reverts all changes made during the transaction.

14. What are stored procedures and functions?
  • A stored procedure is a set of SQL statements that can be executed as a single unit. It can perform

actions such as data modification and return multiple values.
  • A function is a set of SQL statements that perform a specific task and return a single value.

Functions are typically used for calculations and data manipulation.

15. Explain the concept of ACID properties in databases.

ACID stands for Atomicity, Consistency, Isolation, and Durability. These properties ensure reliable

processing of database transactions:

  • Atomicity: Ensures that all operations within a transaction are completed; if not, the transaction

is aborted.
  • Consistency: Ensures that the database remains in a consistent state before and after a transaction.

  • Isolation: Ensures that transactions are isolated from each other, preventing concurrent

transactions from interfering with each other.
  • Durability: Ensures that once a transaction is committed, it remains permanent, even in the case

of a system failure.

16. What is the difference between a VIEW and a TABLE?

  • A TABLE is a database object that stores data in rows and columns.

  • A VIEW is a virtual table based on the result set of a SQL query. It does not store data

physically but provides a way to simplify complex queries and enhance security by restricting access
to specific data.

17. How do you optimize SQL queries?

  • Use indexes to speed up data retrieval.

  • Avoid using SELECT * and only select required columns.

  • Use JOINs instead of subqueries when possible.

  • Write efficient WHERE clauses to filter data early.

  • Analyze query execution plans to identify performance bottlenecks.

18. What is the difference between DISTINCT and GROUP BY?

  • DISTINCT is used to remove duplicate rows from a result set.

  • GROUP BY is used to group rows that have the same values in specified columns and perform

aggregate functions (e.g., COUNT, SUM) on them.

19. Explain the concept of database normalization.
Normalization is the process of organizing data in a database to reduce redundancy and improve
data integrity. It involves dividing large tables into smaller tables and defining relationships between
them. Common forms of normalization are 1NF, 2NF, 3NF, and BCNF.

20. What is the purpose of the ORDER BY clause? The ORDER BY clause is used to sort the result set of a query by one or more columns.
It can be used to sort data in ascending (ASC) or descending (DESC) order.

BEST LUCK !!!

Saturday, December 14, 2024

 ☁️ Cloud Computing for beginners ☁️



Cloud is nothing but a remote a virtual server which is connected over internet, instead of owning and maintaining physical data centers and servers, users and businesses can access these resources on-demand from cloud service providers such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP).

Tuesday, November 12, 2024

The 5 Tech Skills You Need to Succeed in 2025

🌟 **The 5 Tech Skills You Need to Succeed in 2025** 🌟


One more year comes to an end, As the world changes, so do the skills too, lets talk about the skills that are in demand. A few years ago, I thought coding was the only thing I needed to land a tech job. But as I started talking to industry leaders and reading up on trends, I realized there’s more to it, you also need soft skills like communication (verbal, written, active listening) analytical and creative thinking, time management, team work, motivation, self discipline and much more. lets talk about technical now,

Here are 5 tech skills you should master in 2025:

  • Cloud Computing
  • AI & Machine Learning
  • Cybersecurity
  • Data Analysis & Visualization
  • Automation

These skills aren’t just buzzwords; they are shaping the future. The earlier you start, the better. Whether you’re looking to upskill or break into tech, now’s the time to invest in learning these high-demand areas.

Which of these skills are you focusing on this year? Share your thoughts below

Friday, November 8, 2024

Top 10 ASP.NET Core Interview Questions and Answers

 

1. What is ASP.NET Core?

Answer: ASP.NET Core is a cross-platform, high-performance, open-source framework for building modern, cloud-based, and internet-connected applications. It is a redesign of ASP.NET with improved performance, modularity, and ease of deployment.

---------------------------------------------------------------- 

2. What are the key differences between ASP.NET Core and ASP.NET?

Answer:  below are the key differences,

Cross-Platform: ASP.NET Core supports Windows, macOS, and Linux, whereas traditional ASP.NET is primarily Windows-based.

Performance: ASP.NET Core offers improved performance and scalability.

Modularity: ASP.NET Core is more modular with a smaller footprint, thanks to its NuGet package-based architecture.

Hosting: ASP.NET Core can be self-hosted or hosted on IIS, unlike ASP.NET, which relies on IIS.

---------------------------------------------------------------- 

3. Describe the role of the Startup class in ASP.NET Core.

Answer: The Startup class in ASP.NET Core is used to configure services and the app's request pipeline. It typically contains two methods:

ConfigureServices: Used to register services with the dependency injection container.

Configure: Used to define the middleware components that process requests and responses.

---------------------------------------------------------------- 

4. Explain Dependency Injection in ASP.NET Core.

Answer: Dependency Injection (DI) is a design pattern used in ASP.NET Core to achieve Inversion of Control (IoC) between classes and their dependencies. ASP.NET Core has a built-in DI container that allows services to be registered and injected into constructors of classes where they are needed.

---------------------------------------------------------------- 

5. What is middleware in ASP.NET Core and how is it used?

Answer: Middleware in ASP.NET Core is software that is assembled into an app's request pipeline to handle requests and responses. Each piece of middleware can perform operations before and after the next component in the pipeline. Middleware components are added in the Configure method of the Startup class using methods like app.UseMiddleware<>().

---------------------------------------------------------------- 

6. How do you handle configuration in ASP.NET Core?

Answer: Configuration in ASP.NET Core is handled using the ConfigurationBuilder class, which supports a variety of configuration sources such as JSON files, environment variables, and command-line arguments. Configuration settings are typically accessed through the IConfiguration interface.

---------------------------------------------------------------- 

7. How do you handle authentication and authorization in ASP.NET Core?

Answer: Authentication and authorization in ASP.NET Core are handled using middleware and services configured in the Startup.ConfigureServices and Startup.Configure methods. Common authentication options include cookie-based, JWT tokens, OAuth, and identity providers like IdentityServer. Authorization policies and role-based access control are typically configured using the Authorize attribute.

----------------------------------------------------------------

8. What are the benefits of using ASP.NET Core for web development?

Answer:

  • Cross-Platform: Develop on Windows, macOS, and Linux.
  • High Performance: Improved speed and scalability.
  • Unified Framework: Consistent development model for web and cloud applications.
  • Modular: Lightweight, modular framework with NuGet packages.
  • Community Support: Open-source with strong community and Microsoft support.
----------------------------------------------------------------

9. How do you deploy an ASP.NET Core application to a production environment?

Answer: Deployment of ASP.NET Core applications can be done in various ways:

  • Docker: Containerize the application and deploy using Docker.
  • Cloud Services: Use cloud platforms like Azure, AWS, or Google Cloud.
  • IIS: Deploy to IIS on Windows using the Web Deploy tool or manual configuration.
  • Self-Hosting: Use Kestrel or other web servers to host the application directly.

----------------------------------------------------------------

10. What is routing in ASP.NET Core and how is it configured?

Answer: Routing in ASP.NET Core is used to map incoming requests to corresponding endpoints (controllers, actions, Razor Pages). It is configured in the Startup.Configure method using the UseRouting and UseEndpoints methods. 

For example:

app.UseRouting();

app.UseEndpoints(endpoints =>

{

    endpoints.MapControllerRoute(

        name: "default",

        pattern: "{controller=Home}/{action=Index}/{id?}");

});

------------------------------------------------------


3 essential tips for building a winning resume for a developer interview

3 tips for building a winning resume for a developer interview


1. Highlight Technical Skills and Projects

  • Skills Section: Clearly list all relevant technical skills, including programming languages, frameworks, tools, and technologies. Be specific and avoid vague statements.

  • Projects: Include a section for key projects where you can showcase your hands-on experience. Describe your role, the technologies used, and the outcomes. Quantify results when possible (e.g., "Developed a web application that reduced processing time by 30%").

2. Tailor Your Resume for Each Job

  • Customization: Customize your resume for each position by highlighting the skills and experiences most relevant to the job description. Use keywords from the job posting to pass Applicant Tracking Systems (ATS).

  • Objective Statement: Include a concise and compelling objective statement that aligns with the company's goals and the position you’re applying for.

3. Emphasize Soft Skills and Professional Experience

  • Soft Skills: Mention important soft skills such as problem-solving, teamwork, and communication, which are highly valued in development roles.

  • Professional Experience: Outline your professional experience with a focus on achievements and contributions rather than just listing job duties. Use action verbs and quantify achievements to make a stronger impact.

Tuesday, December 3, 2019

SQL Server interview questions

SQL interview Questions

Are you planning for your SQL interview ? Want to crack your SQL Interview ? then go for the SQL Server interview questions book, 


        This book gives you a complete idea about the SQL database. It starts with a very basic concept like what is a database, its usage, types, creation, and data storage, security, sorting, and searching for a stored procedure. This book is a complete set of interview breaking questions and answers with live examples and plenty of screenshots. This book takes you on a journey to mastering the SQL database, including SQL datatypes, functions, triggers, and stored procedures. This book also covers the latest and new features of SQL 2016, 2017 and 2019 CTP with examples.

In the beginner section, we start with very basic concepts like what is a database, why to use a database, different types of database types, what is SQL, its usages, advantage and disadvantages, SQL datatypes, its different operators and how to use them with samples.
In the intermediate section, we will learn about the different SQL functions, SQL Joins (used to fetch values from multiple SQL tables) and SQL DDL, DCL, and DTL commands.
(About the last chapters) This is the advanced section of the book where we have provided an explanation of the SQL stored procedure, triggers, and SQL view concepts, additionally, we have covered SQL core concepts like keys, indexes, injections and constraints. We have also introduced cutting-edge concepts like SSRS, SSIS, SQL Cloud database (Azure), JSON Support and a list of the new features of SQL 2016, 2017, CTP-2019 with SQL performance improvement tips. Finally, we have ended the book with a series of random SQL questions and answers.

TAGLINE 
Let us break the SQL interview with the help of SQL Server interview questions.

KEY FEATURES  
• Database Basic Concepts
• SQL Fundamentals
• DDMS, SQL Statements, and Clauses
• SQL Operators, Datatypes, and Keywords
• SQL Functions, Wildcards and Dates
• SQL Joins and CASE Statement
• SQL DDL, DCL, and DTL Statements
• SQL Stored procedures, Triggers, Views, and Transactions
• SQL Keys, Indexes, Injection, and Constraints
• SSRS, SSIS, SQL Cloud database (Azure), and JSON Support
• New features of SQL 2016, 2017, and 2019
• SQL Performance Improvement Tips
• Fuzzy Interview Questions and Answers


WHAT WILL YOU LEARN  
After reading this book, you will be able to understand SQL database concepts, handle core database activities like data security, searching, migration, and sorting. You will be able to handle the database transactions, use different SQL datatypes, functions, triggers, and stored procedures to save and retrieve data from the database. You will also be able to understand advanced SQL concepts like SQL reporting services, integration services, cloud database and new features from the latest SQL versions like 2016, 2017, and 2019.

WHO THIS BOOK IS FOR 
This book is built in such a way that it is useful for all categories such as technical or non-technical readers. This book is perfect. If you are a fresher and you want to learn about SQL, or if you are a teacher and you want to spread SQL knowledge, this book is very helpful. If you want to crack the database interview or if you are working as a DBA and you want to upgrade your knowledge, or if you are backend developer, database tester, performance , or if your role is that of a database admin, SQL developer, data analyst, mobile app developer or if you are working on core SQL concepts, this book is just right for you.
This book is very useful as it contains many simple real-time scenarios for each concept. All functionalities are explained with real SQL screenshots and database records.

CONTENTS
1. Database and SQL Basics
2. DDMS SQL Statements and Clauses
3. SQL Operators, Keywords, and Datatypes
4. SQL Operators
5. SQL Functions, Wildcards, and Dates
6. SQL Joins and CASE Statement
7. SQL DDL, DCL, and DTL Statements
8. SQL Stored Procedures, Triggers, Views, and Transactions
9. SQL Keys, Indexes, Injections, and Constraints
10. SSRS, SSIS, SQL Cloud database (Azure), and JSON Support
11. New features of SQL 2016, 2017, and 2019
12. SQL Performance Improvement Tips and Fuzzy Interview Questions

https://bpbonline.com/collections/new-relases/products/sql-interview-questions-a-complete-question-bank-to-crack-your-ann-sql-interview-with-real-time-examples

Thanks
Prasad

Thursday, August 29, 2019

Debug your stored procedure.

Getting started

We can debug our .NET application easily using a debugger from debug menu, .NET application has its own .PDB (Program Debug Database) file that used to store Debug location and increment linking of debug configuration. This all about .NET but can we debug our stored procedures? Answer is YES, we can debug our stored procedure. Let's find out How to do it.
Stored procedures are popular enough due to their features like enhanced security, separation is possible in data functionality and application, improved performance (as fewer call made to database), basically it's a one time and one place processing theme. SP (stored procedure) is now more popular in DBA and Developer crowd, But after writing large SP's, how to debug them ? How to test them if they are running properly
So here is the need to Debug stored procedure, Let's see what we need to debug it.

Bit by bit

1. First step is to create a Stored procedure (if you have stored procedure already created then you can skip this step), Here i am creating a simple Stored procedure, which select record from EMP table for specific ID, see below snap
Image 1
2. After stored procedure created successfully, we are ready to debug it. Basically There are couple of ways to debug stored procedure
  1. Using SQL Management studio (SSMS)
  2. Using Visual Studio
Will see how to Debug it using SQL Management studio (I am using SQL 2008R2 Express)
  • Open SQL 2008 R2
  • Click on ViewMenu --> Object Explorer
  • Click on Connect database engine  --> Enter username and password for SQL database --> Connect to database, see below snippet
            Image 2
  • Expand Database --> Select Programmability folder --> Stored Procedures (You will see your procedure here)
            Image 3
  • Open New Query window by right click on database and click on 'New Query'
  • Write statement 'Exec ProcedureName' (in my case its procedure name is 'sp_empInfo')
  • Put Debugger on that line using key F9
            Image 4

  • Select Green arrow (debug) from SQL and your debugger gets start, Press F11 to step in to procedure
  • You can see output in 'local' and 'callstack' window
          Image 5
Debug it using Visual Studio
Same way you can use Visual Studio to debug the stored procedure
  • Go to Visual studio and connect database. follow below steps
  •  Open Visual studio editor
  •  Click on ViewMenu --> SQL Server object Explorer (Before VS 2012 it was Server explorer)
            Image 6
  •  In SQL Server object Explorer Pane right click on Data Connections
  •  Select Add connection
  •  Enter credential (like SQL instance, SQL server user name, Password, database name)
  • Right click on database and allow 'Application debugging' and 'Allow SQL/CLR debugging', see below snap
           Image 7
  • Expand Database --> Select Programmability folder --> Stored Procedures
  • Right click procedure --> Select 'Debug Procedure'
           Image 8
You can start Debug from now.

Exceptions

Access permission is the biggest issue while debug stored procedure,
Common Error Messages
following are the common error messages occurred during debug stored procedure
  1. Unable to start the transact-SQL debugger, could not connect to the Database Engine instance...
  2. Unable to start T-SQL debugging, Could not connect to computer...
  3. Logon failure: Unknown username or bad password...
  4. Failed to start debugger, The execute permission was...
  5. Could not attach to SQL Server process on...
see some exceptions/errors snap below
Image 9
Following exception occurred when you tried to debug Remote stored procedure
Image 10
Common points to avoid error while debugging
To resolve above errors you can try out following workarounds
  1. If you are debugging stored procedure on local SQL server then your local SQL user should be in 'sysadmin' role, to add user in sysadmin role, run below stored procedure (it is inbuilt), see below syntax
  2. sp_addsrvrolemember '<Login>', 'sysadmin'
  3. Configure TCP port in Windows firewall to enable t-SQL Debugging, for details see MSDN link
  4. Configure TCP port in Windows firewall to enable for remote t-SQL Debugging (when SQL server is different and want to Debug it from client machine) see MSDN link, For remote debugging in either case you can use Windows local or domain account authentication
  5. Open firewall ports on both SQLserver machine as well as client, PORTS: TCP 139, TCP 445, UDP 137 and UDP 138 
  6. SQL management Studio is should be lunched with “Run an administrator…”
  7. Management studio(Client machine) and Server (SQL) should be in same domain, otherwise you need to setup account with same Username and password

What we learn !

We can debug stored procedure by using Visual studio or by using SSMS (Sql management studio), we can use local variables, call stack windows for that. You can provide parameters to stored procedure (if any) and get instant debugger on it. 
Hope it will be useful in daily .NET/SQL life. 

Thanking You
- Prasad