-2

I have a Table called Students, with the columns:

Name nvarchar(100)
LastName nvarchar(100)
Age int
Weight decimal
Height decimal
Adress nvarchar(200)

Does the following query:

SELECT Name, LastName, Age, Weight, Height, Adress FROM Students

…. will be affected by time changing the column order?

Example:

SELECT  Height, Age, Weight, LastName, Name Adress FROM Students
James Z
  • 12,209
  • 10
  • 24
  • 44
  • 1
    http://dba.stackexchange.com/questions/18719/does-the-order-of-columns-in-a-tables-definition-matter and http://stackoverflow.com/a/6692107/2055998 – PM 77-1 Jan 06 '17 at 18:41
  • @PM77-1 I think the OP asked about the order in the query, not in the table created. – DVT Jan 06 '17 at 18:42
  • Well, have you tried it and made some observations about if there is a difference? What did you find? This seems like a fairly straightforward thing to answer. – dfundako Jan 06 '17 at 18:43
  • 1
    Simple answer is NO – Rahul Jan 06 '17 at 18:53
  • 1
    Possible duplicate of [Does column ordering affects performance in Microsoft SQL Server 2012?](http://stackoverflow.com/questions/12271766/does-column-ordering-affects-performance-in-microsoft-sql-server-2012) – Tab Alleman Jan 06 '17 at 19:20
  • Why would you think it does? And, having gotten this suspicion, why wouldn't you go to the trouble of testing it yourself, or thinking up plausible ways where an implementation could run into timing differences? Because if you did, you'd hopefully find those in very short supply, or (if you lack the necessary background knowledge to tell one way or the other) you'd find the motivation to find out how the query engine works beyond the superficial. – Jeroen Mostert Jan 06 '17 at 19:39

1 Answers1

0

No.

Query optimizer first build query execution plan before actually execute it.

A query is not an instruction that you give to engine execute it and return the data.
It is a declaration of the data that you engine give you.

That's a reason why SQL is a declarative language and not procedural.

The engine will receive the request and execute it in the way that it finds more optimal.

Andre Figueiredo
  • 12,930
  • 8
  • 48
  • 74