codebyo (11/29/2011)
I usually code my INSERTs like this whenever possible:
INSERT INTO #ATable
(
Col1,
Col2,
Col3
)
VALUES
(
2 AS Col1,
1 AS Col2,
3 AS Col3
);
I'm not sure if it's a good way of doing it but it looks clear to me. 🙂
I'm not really too fond about the aliases; I think it'd be better to use comments - as that is the only function the alias serves anyway.
Other than that, this method is fine - as long as the comments and the actual columns match up. But what happens if a change is made somewhere and the comments are not updated? If that happens a few time, developers will end up ignoring the column names in the comments (or aliases), as they know that those aren't always reliable - and than it's back to counting the 23rd column name from the list. :crying: