Showing posts with label conversion. Show all posts
Showing posts with label conversion. Show all posts

Wednesday, October 9, 2013

CONVERT DATETIME seems all right, but still ...

A table with a varchar column that has date and other value types too.
A query with a simple CONVERT DATETIME

Conversion failed when converting date and/or time from character string.
Crashing. Over and over again. I start to call it X-Files.
Until I read THIS.

Not only I know why it happened (and sortof feel like SQL is "stupid" :D) but I get an interesting idea to work around the issue.

Friday, March 6, 2009

Float vs. Decimal

I used float instead of decimal, I'll never do that again.
I found some stored procedures, that had numeric parameters used as varchar. I'll never do that either.
Check out why:

1st case:





declare @a as float
set @a = 13705.05
select @a

declare @b as varchar(100)
set @b = @a
select @b





2nd case:





declare @a as float
set @a = 137.86
select @a

declare @b as varchar(100)
set @b = @a
select @b





Run them, You'll get this:
1st case:

13705.05
13705

2nd case:

137.86
137.86

see my point?