Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


TSQL


TSQL

Author
Message
SQLEnthusiastic
SQLEnthusiastic
SSC Veteran
SSC Veteran (209 reputation)SSC Veteran (209 reputation)SSC Veteran (209 reputation)SSC Veteran (209 reputation)SSC Veteran (209 reputation)SSC Veteran (209 reputation)SSC Veteran (209 reputation)SSC Veteran (209 reputation)

Group: General Forum Members
Points: 209 Visits: 103
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.
ppcx
ppcx
SSC-Addicted
SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)

Group: General Forum Members
Points: 415 Visits: 431
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. w00t

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
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)

Group: General Forum Members
Points: 44958 Visits: 39862
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.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is usually not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10688 Visits: 11991
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

Jon Summers
Jon Summers
SSC-Addicted
SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)SSC-Addicted (484 reputation)

Group: General Forum Members
Points: 484 Visits: 45
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
Ashok Kumar-377014
Ashok Kumar-377014
SSC Journeyman
SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)

Group: General Forum Members
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
Nitu for u
Nitu for u
SSC-Addicted
SSC-Addicted (412 reputation)SSC-Addicted (412 reputation)SSC-Addicted (412 reputation)SSC-Addicted (412 reputation)SSC-Addicted (412 reputation)SSC-Addicted (412 reputation)SSC-Addicted (412 reputation)SSC-Addicted (412 reputation)

Group: General Forum Members
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.
kapil_kk
kapil_kk
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2417 Visits: 2763
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?

_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search