|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, September 25, 2012 4:03 AM
Points: 185,
Visits: 52
|
|
| Comments posted to this topic are about the item TSQL
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Wednesday, October 31, 2012 3:59 AM
Points: 215,
Visits: 166
|
|
Hi there
I work in a SQL 2000 developer edition. when I run the provided script, it runs successfully returning rows 1 through 6.
Only if I run the script, without the from subselect, does it return a conversion error.
Why is that?
Marius
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Tuesday, April 23, 2013 8:00 AM
Points: 1,065,
Visits: 698
|
|
When the SELECT statement is compiled for the INSERT, the first value is implicitly taken as an INT. In the UNIONs, as each SELECT is added, they must match this data type.
If that is the correct explanation, would the next statement work? Insert into test Select 'A' union Select 1;
(Answer: No)
Dutch Anti-RBAR League
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 1:09 AM
Points: 23,
Visits: 102
|
|
Hi, The answer given here is wrong.The correct answer will be 1 2 3 4 5 6
Thanks.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Wednesday, June 13, 2012 1:23 AM
Points: 2,162,
Visits: 170
|
|
Hi
The given script will work in SQL Server 2000 giving the results 1,2,3,4,5,6. In SQL Server 2008 it fails saying conversion failed when converting the varchar value 'A' to data type int.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Thursday, April 19, 2012 4:50 AM
Points: 284,
Visits: 52
|
|
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.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: 2 days ago @ 8:33 AM
Points: 2,723,
Visits: 987
|
|
On SQL 2005 it also works, so in that case answer c is the correct one.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Wednesday, October 31, 2012 3:59 AM
Points: 215,
Visits: 166
|
|
I'm glad to see my thinking (from a SQL 2000 point of view) was at least in line with some other folks as well. Unfortunately this didn't get us the points 
I agree: indicating the version of SQL the script was written in would have helped...
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 4:24 AM
Points: 1,026,
Visits: 752
|
|
What a crap question.
Can someone adjust this, its pretty bad. Plain wrong, in fact.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 2:56 AM
Points: 2,008,
Visits: 2,469
|
|
I ran this script it in sql2000. it is working fine. it shows 1,2,3,4,5,6. so the correct answer is c.
karthik
|
|
|
|