When I run query in excel it gives result with different column sequence. The same query gives result with different column sequence when used in query analyzer or VBA Macro. Somebody solve this mystery.
The order of the records and the order of the columns are irrelevant in a relational database. I don't know why the columns are different between those two systems, but it is irrelevant (though admittedly, it can be a nuisance).
The general rule is :
SELECT * FROM MyTable
to quickly check something in interactive mode, never use it in production code.
You should always access the columns in an explicit way, like:
SELECT column_A, Column_B, Column_C FROM MyTable
With kind regards . . . . . SQL Server 2000/2005/2012
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2. Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages