INSERT INTO - more reliable?

SoftwareEng

Senior member
Apr 24, 2005
553
4
81
Hey guys,

In SQL Server there are 2 ways to do an INSERT: by listing column names, or by ommiting them:

INSERT INTO Table1 (Column1, Column2, Column3?)
VALUES (Value1, Value2, Value3?)

vs

INSERT INTO Table1
VALUES (value1, value2, value3?)

Which one is better? I am more concerned with readability, reliability, and ease of maintenance than performance.

Thank you!
 

bsobel

Moderator Emeritus<br>Elite Member
Dec 9, 2001
13,346
0
0
Including the column name is more portable since if you change the table layout your code doesnt break.

 

Pacemaker

Golden Member
Jul 13, 2001
1,184
2
0
I agree as well.

1) It reduces the chance of a mistake
2) It increases readability
3) It is much easier to make changes to
4) Changing the table doesn't break the insert.
 

JACKDRUID

Senior member
Nov 28, 2007
729
0
0
INSERT INTO Table1
(Column1, Column2, Column3?) VALUES
(Value1, Value2, Value3?)

will improve readability