﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Carlo Romagnano  / CASTing / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 22:58:25 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: CASTing</title><link>http://www.sqlservercentral.com/Forums/Topic508168-1299-1.aspx</link><description>[quote] think these two QODs really show how evil implicit type conversions are.Id rather spend this one second on explicit type conversion than on reviewing such code for possible data loss caused by implicit conversion. I had to look at this QOD for at least 5 seconds before I made my choice. Sum this up for all your code and then tell me: wouldn't it be great if the compiler told you when you had missed a type conversion?Sure, you have a test team, but why not catch an error in the first place?Isn't a database a realm where datatypes should be handled in the most strict way?Just some thoughts in the late evening :-) Best Regards,Chris Büttner [/quote]I totally agree after thinking about these two QOD (great ones, btw).  Is there a way to enable explicit (strict) conversions when writing stored procedures in SQL 2005?</description><pubDate>Fri, 30 May 2008 10:55:47 GMT</pubDate><dc:creator>Michael Spencer</dc:creator></item><item><title>RE: CASTing</title><link>http://www.sqlservercentral.com/Forums/Topic508168-1299-1.aspx</link><description>Thanks for the clarification.  :D</description><pubDate>Fri, 30 May 2008 05:42:17 GMT</pubDate><dc:creator>dan.deluna</dc:creator></item><item><title>RE: CASTing</title><link>http://www.sqlservercentral.com/Forums/Topic508168-1299-1.aspx</link><description>I think these two QODs really show how evil implicit type conversions are.Id rather spend this one second on explicit type conversion than on reviewing such code for possible data loss caused by implicit conversion. I had to look at this QOD for at least 5 seconds before I made my choice. Sum this up for all your code and then tell me: wouldn't it be great if the compiler told you when you had missed a type conversion?Sure, you have a test team, but why not catch an error in the first place?Isn't a database a realm where datatypes should be handled in the most strict way?Just some thoughts in the late evening :-)</description><pubDate>Thu, 29 May 2008 14:01:44 GMT</pubDate><dc:creator>Christian Buettner-167247</dc:creator></item><item><title>RE: CASTing</title><link>http://www.sqlservercentral.com/Forums/Topic508168-1299-1.aspx</link><description>Great question.Didn't fall into the trap, but only because I remembered the question 2 days ago and thought there must be something else going on.Its got me thinking a lot more about types and implicit conversions. Thanks</description><pubDate>Thu, 29 May 2008 09:30:02 GMT</pubDate><dc:creator>Biggles-581128</dc:creator></item><item><title>RE: CASTing</title><link>http://www.sqlservercentral.com/Forums/Topic508168-1299-1.aspx</link><description>Yeah, so did I.  I see what happened now.John</description><pubDate>Thu, 29 May 2008 08:49:05 GMT</pubDate><dc:creator>John Mitchell-245523</dc:creator></item><item><title>RE: CASTing</title><link>http://www.sqlservercentral.com/Forums/Topic508168-1299-1.aspx</link><description>Good question of the day...I totally fell for it!</description><pubDate>Thu, 29 May 2008 08:47:42 GMT</pubDate><dc:creator>Jason Shadonix</dc:creator></item><item><title>RE: CASTing</title><link>http://www.sqlservercentral.com/Forums/Topic508168-1299-1.aspx</link><description>nvarchar has a max length of 4000 not 8000the  'N'  in this statment converts it;[code]set @c = N'hello'[/code]</description><pubDate>Thu, 29 May 2008 08:41:55 GMT</pubDate><dc:creator>steveb. </dc:creator></item><item><title>RE: CASTing</title><link>http://www.sqlservercentral.com/Forums/Topic508168-1299-1.aspx</link><description>Does that mean this 2 lines below, converts @c to nvarchar(8000)?meaning ANY casting to nvarchar always give it maximum length of 8000?[quote]declare @c varchar(800)set @c = N'hello' [/quote]I think I got lost by reading this sentence ... maybe I shouldn't read it anymore[quote]The CAST to nvarchar(800) has a maximum 4000 character len.[/quote]</description><pubDate>Thu, 29 May 2008 08:36:34 GMT</pubDate><dc:creator>Jerry Hung</dc:creator></item><item><title>RE: CASTing</title><link>http://www.sqlservercentral.com/Forums/Topic508168-1299-1.aspx</link><description>The one two days ago was casting to a length greater than the nvarchar data type max of 4000, so the length was truncated to 4000.   The one today was casting to a length less than 4000 so it stayed the same.</description><pubDate>Thu, 29 May 2008 08:25:13 GMT</pubDate><dc:creator>steveb. </dc:creator></item><item><title>RE: CASTing</title><link>http://www.sqlservercentral.com/Forums/Topic508168-1299-1.aspx</link><description>me a little bit confused too, what's the difference between this Question, and the one 2 days ago?TODAY[quote]CASTingSecond question of day: what is the len of @c?declare @c varchar(800)set @c = N'hello' + replicate('-',800)print len(@c)print @c	Sorry - you were wrongCorrect answer: 	800Explanation: 	The CAST to nvarchar(800) has a maximum 4000 character len. The CAST then to varchar(800) fits in that space, so the len is 800[/quote]2 days ago[quote]CASTingFirst question of day: what is the len of @c?declare @c varchar(8000)set @c = N'hello' + replicate('-',8000)print len(@c)print @cYou got it right!Correct answer: 	4000Explanation: 	The CAST to NVARCHAR(4000) means that the maximum len is 4000, then the cast to varchar(8000) allows more characters, but the string is already truncated.[/quote]</description><pubDate>Thu, 29 May 2008 08:13:07 GMT</pubDate><dc:creator>Jerry Hung</dc:creator></item><item><title>RE: CASTing</title><link>http://www.sqlservercentral.com/Forums/Topic508168-1299-1.aspx</link><description>Sorry, I don't understand.  [i]What[/i] CAST to nvarchar(800)?  Is there a typo in the question?John</description><pubDate>Thu, 29 May 2008 01:21:02 GMT</pubDate><dc:creator>John Mitchell-245523</dc:creator></item><item><title>CASTing</title><link>http://www.sqlservercentral.com/Forums/Topic508168-1299-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/Data+Types/62877/"&gt;CASTing&lt;/A&gt;[/B]</description><pubDate>Wed, 28 May 2008 22:41:09 GMT</pubDate><dc:creator>Carlo Romagnano</dc:creator></item></channel></rss>