0

I have a Query requiring Varchar to be converted into INT. Iam not currently posting the query itself as I do not believe the problem to be there.

I setup the query on my home PC using a backup from the servers SQL file. I have Server 2008 R2 installed on both machines.

The Query runs 100% on my PC but gives an error converting varchar to INT when run on the server.

Iam guessing there is a setting somewhere that is not the same? I have checked Regional settings and the problem is not there. any ideas?

Frans
  • 1

1 Answers1

1

The problem lies in how the query is evaluated. You have no guarantee or what order parts of the query will be evaluated in, so on one machine a filter may happen after a convert, on another it could do. Or the WHERE clause conditions can be evaluated in a different order

SQL is declarative, not procedural. With SQL you ask for what you want and the query optimiser honours that how it sees fit. In a procedural language (C#, Java etc) you'd control the execution order.

The reason is full described here: Why use Select Top 100 Percent?

Community
  • 1
  • 1
gbn
  • 422,506
  • 82
  • 585
  • 676