|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Sunday, June 12, 2011 5:00 PM
Points: 195,
Visits: 80
|
|
As I said before, the script in questions works fine in 2000 and 2005 as well.
Without the INSERT, if you only SELECT it doesn't. The SELECT with different datatypes, does not do an implicit conversion.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Yesterday @ 4:08 PM
Points: 220,
Visits: 352
|
|
RBarryYoung (4/8/2009)
Jochen Vleming (4/8/2009)
Julie Breutzmann (3/26/2009) While the question and answer were not ideal, this question was valuable to me because I learned so much from the discussion that followed.I totally agree with Julie on this. I'd rather learn a valuable lesson without getting points than learning nothing while getting thousands of points.  Jochen Actually, you get far more points by participating in the discussion. That's one of the nice things about the point system on this site. That's very true. Just look at the Top QotD points versus the Top Forum Posters points: http://www.sqlservercentral.com/TotalScores
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Yesterday @ 4:51 PM
Points: 32,923,
Visits: 26,811
|
|
arconen (3/26/2009) In future must show the version of MS SQL Server in order to prevent a misunderstanding. I answered right for version 2000, but for 2008 I made a mistake.
I absolutely agree with that. And, it brings up another huge problem... these type of changes to the database engine are complete and utter non-sense that break huge amounts of code. Such "improvements" to the engine cause more pain than the Y2K problem ever thought of causing.
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 12:25 PM
Points: 7,110,
Visits: 7,184
|
|
My take on ths is that SQL 2008 has introduced a serious defect! Changing to behave in this irrational manner has probably broken rather a lot of SQL.
And since the behaviour in SQL 2008 is different from the behaviour in all previous versions, it would have been useful (to say the least) if the question had specified teh version.
Tom Is minic a gheibheann béal oscailte dorn dúnta. Is minig a cheapas beul fosgailte dòrn dùinte.
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Saturday, November 03, 2012 7:41 AM
Points: 449,
Visits: 41
|
|
With SQL Server 2005, I am able to create the table with no error, so the answer is wrong. However, when subsequently I query the table, the conversion error appears. 1 "SELECT col FROM test" succeeds => 1234567ABCD 2 "SELECT col FROM test WHERE IsNumeric(col)=1" succeeds => 1234567 3 The query given fails with the conversion error
Regards, Jon Summers
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Sunday, March 07, 2010 11:12 PM
Points: 76,
Visits: 32
|
|
Hi there
I work in a SQL 2000 developer edition. when I run the provided script, it runs successfully returning rows 1 through 6.
I did not dound any conversion error.
Ashok
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Friday, March 11, 2011 6:14 AM
Points: 412,
Visits: 27
|
|
This works Insert into test Select 'A' union Select 1;
also Insert into test Select 1 union Select 'A'; works
but only select statement not works. Select 1 union Select 'A'; Give error : Syntax error converting the varchar value 'A' to a column of data type int.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Sunday, May 19, 2013 11:16 PM
Points: 1,061,
Visits: 1,151
|
|
good explanation John.... the error is coming due to incompatibility of datatypes in UNION....
but if we do like this -
DECLARE @id varchar(10) set @id = 'A' select isnumeric(@id) It always gives 1
why?
|
|
|
|