Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««123»»

Coalesce and Conversion Expand / Collapse
Author
Message
Posted Tuesday, January 8, 2013 7:20 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:08 PM
Points: 13,206, Visits: 12,687
Good question Tom. Good to have a refresher on these things from time to time.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1404232
Posted Tuesday, January 8, 2013 8:25 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 2:07 AM
Points: 4,101, Visits: 5,456
Tripped myself on this one.
Thanks Tom, learned something today, so I guess that makes it worthwhile


____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1404277
Posted Tuesday, January 8, 2013 9:14 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 12:51 PM
Points: 2,010, Visits: 10,969
Excellent question, and great explanation! Thanks!


Rob Schripsema
Accelitec, Inc
Post #1404316
Posted Tuesday, January 8, 2013 10:32 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, August 28, 2014 8:53 PM
Points: 1,388, Visits: 3,039
How annoying. You made me think! ;)

I agree this was an excellent question and explanation. I do see that one minor correction could be needed to one example given, however. You say "...for example the numeric value 37.2 can be converted to an int (37)...". Did you actually mean that an INT (@i) could be converted to the higher precedence numeric type, as obviously could be the literal value 37.2? After all, the result of that coalesce is 37.2 and not 37.
Post #1404373
Posted Tuesday, January 8, 2013 12:07 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Friday, October 24, 2014 12:43 PM
Points: 4,126, Visits: 3,428
A really good QotD. Thanks, Tom!
Post #1404418
Posted Tuesday, January 8, 2013 10:07 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, October 16, 2014 10:02 AM
Points: 1,372, Visits: 1,566
Very nice question Tom. Learnt something new today

~ Lokesh Vij

Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions

Link to my Blog Post --> www.SQLPathy.com

Follow me @Twitter

Post #1404540
Posted Tuesday, January 8, 2013 10:20 PM


SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, January 24, 2013 6:08 AM
Points: 28, Visits: 136
thanks good and very tough question!

_______________________________________________________________
"The best way to prepare for programming is to write programs, and
to study great programs that other people have written." – Bill Gates
Post #1404541
Posted Wednesday, January 9, 2013 12:01 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 4:29 AM
Points: 3,559, Visits: 2,671
Great question, must say. +1
Post #1404562
Posted Wednesday, January 9, 2013 7:03 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 9:17 AM
Points: 1,029, Visits: 2,335
Interesting question, thank you Tom.

(even kind of knowing the output for each select statement, it tempted me to challenge self and to prove it)


ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
Post #1404756
Posted Wednesday, January 9, 2013 7:35 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 1:23 PM
Points: 1,951, Visits: 1,473
Thanks for the great question Tom. It really made me think; there were so many choices and it was so early in the morning. I can definitely say I'm awake now.



Everything is awesome!
Post #1404786
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse