Getting started with Azure Developer CLI (azd)
March 12, 2025Dynamics 365 Blog | Accelerate your journey to AI-first selling with Microsoft AI Accelerator for Sales and new sales agents
March 12, 2025To insert new rows into a table, you will mostly use the INSERT statement.
In the example above, I’ve inserted one row into the dbo.CinemaGroups table. There are a few aspects to this statement.
First, you should always use two-part names for the table i.e., use dbo.CinemaGroups not just CinemaGroups.
Second, there is an optional INTO keyword for INSERT statements. You can say INSERT INTO dbo.CinemaGroups. While I’m generally pretty pedantic about these things, I can’t see any value that the word INTO adds here and I don’t use it. (Worth noting that other dialects of SQL like the one in Access, insist that it’s there).
Third, the list of columns is optional. If I was inserting a row in order with every column in the table, I could leave that out. But I would suggest you never do that because including it makes it very, clear what you’re inserting. And, it makes for more robust code. The statement will still work if, at the back end, someone added columns to the table, or recreated the table with the same columns but in a different order.
Fourth, the list of values can include variables.
Learning T-SQL
It’s worth your while becoming proficient in SQL. If you’d like to learn a lot about T-SQL in a hurry, our Writing T-SQL Queries for SQL Server course is online, on-demand, and low cost.
The post T-SQL 101: #128 Inserting Data into a Table using SQL Server T-SQL appeared first on The Bit Bucket.