January 28, 2016 at 10:31 pm
This was removed by the editor as SPAM
January 29, 2016 at 1:11 am
Good question, thanks
...
January 29, 2016 at 5:29 am
A simple one to end the week. Thanks.
January 29, 2016 at 6:19 am
Easy one, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
January 29, 2016 at 6:31 am
I knew that coalesce would return the highest data type but never remember the ordering of that so I thought it was either going to be 10 or divide by zero error. I got a surprise when I checked on the value of @float:
[font="Courier New"]print @float = 1
select @float = .5
[/font]
Can somebody explain why that is?
January 29, 2016 at 7:06 am
tom.w.brannon (1/29/2016)
I knew that coalesce would return the highest data type but never remember the ordering of that so I thought it was either going to be 10 or divide by zero error. I got a surprise when I checked on the value of @float:[font="Courier New"]print @float = 1
select @float = .5
[/font]
Can somebody explain why that is?
Probably it is a rounding from .5 to 1.
What type is @float ?
Iulian
January 29, 2016 at 7:20 am
I spent way to long on this one looking for the data type precedence catch. :crazy:
January 29, 2016 at 8:05 am
tom.w.brannon (1/29/2016)
I knew that coalesce would return the highest data type but never remember the ordering of that so I thought it was either going to be 10 or divide by zero error. I got a surprise when I checked on the value of @float:[font="Courier New"]print @float = 1
select @float = .5
[/font]
Can somebody explain why that is?
Can you post the exact code that you're using? Float shouldn't be rounded to 1.
January 29, 2016 at 8:27 am
Sneaky. When I first looked at it, I took 5,500 to be 5500 instead of two distinct arguments.
Don Simpson
January 29, 2016 at 9:28 am
Luis Cazares (1/29/2016)
tom.w.brannon (1/29/2016)
I knew that coalesce would return the highest data type but never remember the ordering of that so I thought it was either going to be 10 or divide by zero error. I got a surprise when I checked on the value of @float:[font="Courier New"]print @float = 1
select @float = .5
[/font]
Can somebody explain why that is?
Can you post the exact code that you're using? Float shouldn't be rounded to 1.
Sorry, I made a mistake. Both print and select give back .5. Not sure what I was looking at.
DECLARE @int1 INT,
@int2 INT,
@float FLOAT
SET @float = COALESCE
(@int1,
@int2,
.5)
SELECT COALESCE
(@int1,
5,500)
/ @float
print @float;
select @float;
January 31, 2016 at 1:58 am
Hmm. I thought COALESCE will return the datatype of the leftmost parameter. Learnt something. Thanks.
January 31, 2016 at 7:21 am
palotaiarpad (1/31/2016)
Hmm. I thought COALESCE will return the datatype of the leftmost parameter. Learnt something. Thanks.
ISNULL() does work that way.
February 1, 2016 at 12:36 am
Simple one 🙂
February 3, 2016 at 6:13 am
Still a week-end question for tired persons.
It is an easy question to reply as soon as you know that a variable declared thru the Declare statement is always initialized to a null value when it is not initialized inside the Declare or by a SET statement ( before its 1st use.
I recognize that I have forgotten this "special" way of initialization up to a session of SQL Server Days related to the basics of T-SQL I participated for the release of SQL Server 2008 R2. As it is now anchored in my memory , the choice was easy. A prof that even a basic session can be useful for a man who began with SQL Server 6.5. Since I have used nearly all versions except the 7.0 . I have to recognize that I am using T-SQL but it is not my favorite topic.
Anyway , thanks for this easy question which permits to dig deeply inside my old memory.
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply