0

Using MS SQL 2000 it was possible to have a query such as:

SELECT (Code + ' = ' + EdiNumber + ',') AS MyResult FROM tblCountry

Which would give you a list of results like:

MyResult
========
ZW = 263,
ZA = 27,
...

However, in MS SQL 2008 that query returns:

-1 records affected

Does anyone know a) Why? and b) How to get the SQL 2000 result from SQL 2008?

UPDATE

Im just using a standard ASP.NET connection string to connect to the database using a console to post the query:

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyDB.mdf;Integrated Security=True;User Instance=True; Database=MyDB
StevieG
  • 8,639
  • 23
  • 31
Jimbo
  • 22,379
  • 42
  • 117
  • 159

1 Answers1

0

PROBLEM SOLVED

-1 records affected was clearly the non-privileged result because all that was actually happening was an error in the query whilst trying to concatenate a string (Code) and an int (EdiNumber)

The correct query should have been:

SELECT (Code + ' = ' + CAST(EdiNumber AS VARCHAR) + ',') as MyResult FROM tblCountry

Once I got that correct, the query worked fine from the original console.

Jimbo
  • 22,379
  • 42
  • 117
  • 159