SQL: How to insert data into a table with column names

Viewed 13473

When inserting data into a SQL Server table, is it possible to specify which column you want to insert data to?

For a table with

I know you can have syntax like this:

INSERT INTO MyTable (Name, col4_on, col8_on, col9_on)
VALUES ('myName', 0, 1, 0)

But the above syntax becomes unwieldy when you have lots of columns, especially if they have binary data. It becomes hard to match up which 1 and 0 go with which column. I'm hoping there's a named-parameter like syntax (similar to what C# has) which looks like the following:

INSERT INTO MyTable 
VALUES (Name: 'myName', col4_on: 0, col8_on: 1, col9_on: 0)

Thanks

5 Answers
Related