SQL Server is a powerful relational database management system (RDBMS) developed by Microsoft. A fundamental operation in SQL is the insertion of data into tables. W3Schools, a renowned website known for its programming and web development tutorials, provides an easy-to-understand guide for SQL Server INSERT INTO command. Let's delve into this topic to help you master data insertion.

Before we get started, ensure that you have an understanding of SQL Server and have access to SQL Server Management Studio (SSMS) or a similar environment to run your SQL statements. Let's now explore how to use the SQL Server INSERT INTO command with W3Schools as our roadmap.

Understanding SQL Server INSERT INTO Command
The SQL Server INSERT INTO command is used to insert new records into a table. It has the following basic syntax:

INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...)
Inserting a Single Row

To insert a single row into a table, use the following syntax:
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway')
The above statement inserts a new record into the 'Customers' table with the provided columns and values.

Inserting Multiple Rows
You can also insert multiple rows at once using the following syntax:
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway'), ('Berger', 'Steve Smith', 'Berger Blvd 67', 'Paris', '75001', 'France')

This statement inserts two new records into the 'Customers' table.
Using SELECT to Insert Data




















SQL Server allows you to insert data from one table to another using the SELECT statement.
Inserting Data from Another Table
To insert data from one table to another, use the following syntax:
INSERT INTO Customers_New (CustomerName, ContactName, Address, City, PostalCode, Country) SELECT CustomerName, ContactName, Address, City, PostalCode, Country FROM Customers
This statement creates a new table 'Customers_New' and inserts all records from the 'Customers' table.
Inserting the Result of an Expression
You can also insert the result of an expression. For example, to insert the count of customers from each city, use the following:
INSERT INTO CityCount (City, Count) SELECT City, COUNT(*) FROM Customers GROUP BY City
This statement inserts a new table 'CityCount' with the city and the count of customers for each city.
The SQL Server INSERT INTO command offers a powerful way to insert data into tables, making it an essential operation in database management. W3Schools serves as an excellent resource for mastering this command and many others in the SQL Server arsenal. Keep practicing and exploring new features to become an SQL Server expert.