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

Tuesday, March 20, 2012

big problem with data conversion

Dear colleagues, I have a big problem with data conversion. For example, on my Windows form (C#) i have one text box and in my table I have field type float. When I use following conversion or casting:

float i = (float)Convert.ToDouble(textBox1.Text);

and insert number 12,3 in my table I have following number 12.30000000000032324!

What I must to do with this conversion and have in my table number 12,3?

Hi,

although this is not a C# forum, you should take a look at the Help for a more precise datatype than float.

http://msdn2.microsoft.com/en-us/library/b1e65aza.aspx

In addition see the float definition in the BOL for more information about float in SQL Server.

You might want to have a look on the decimal type instead.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

Monday, March 19, 2012

Big Int to Date Conversion

Hi Guys!!!
i really need your help now. i tried my level best to make some
tricks on this problem but didn't make it.
i've got a Big Int datatype column contains the "Ticks" (Long value)
and i want to convert it into DateTime but i'm not able to do it. the
value is like this 632557193645506250 i want to convert it into
datetime format.
please help me out guys. i'm using ms sql server 2000.
and front end is vs .net 2005
i want to do it into sql Query please dont ask me the reason but
because of some constraints i can not do it in .net
PLEASE HELP ME GUYS.
hi,
Lucky wrote:
> Hi Guys!!!
> i really need your help now. i tried my level best to make some
> tricks on this problem but didn't make it.
> i've got a Big Int datatype column contains the "Ticks" (Long value)
> and i want to convert it into DateTime but i'm not able to do it. the
> value is like this 632557193645506250 i want to convert it into
> datetime format.
> please help me out guys. i'm using ms sql server 2000.
> and front end is vs .net 2005
> i want to do it into sql Query please dont ask me the reason but
> because of some constraints i can not do it in .net
>
> PLEASE HELP ME GUYS.
DATEDIFF() and DATEADD() builtin functions expect a parameter of the "int"
datatype... id you perform
SET NOCOUNT ON;
DECLARE @.d datetime, @.t bigint;
SET @.t = 632557193645506250;
SELECT @.d = DATEADD (ms, @.t, '19000101');
SELECT @.d AS [date as difference in ms from 01/01/1900];
which adds the specified num of ticks to a base data value (you are required
to know in order to perform calculation), you get
Server: Msg 8115, Level 16, State 2, Line 4
Arithmetic overflow error converting expression to data type int.
date as difference in ms from 01/01/1900
NULL
as the provided "difference" exceeds the max supported value...
http://msdn.microsoft.com/library/de...da-db_3vtw.asp
if you can "convert" that big value into separated values as "days" for the
date part and "ms" (depending on the actual precision you are required to
provide) for the time part in order not to overflow the int datatype
(32767), you can easely use the DATEADD(..) function..
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.18.0 - DbaMgr ver 0.62.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||On Tue, 4 Apr 2006 19:18:30 +0200, Andrea Montanari wrote:

>if you can "convert" that big value into separated values as "days" for the
>date part and "ms" (depending on the actual precision you are required to
>provide) for the time part in order not to overflow the int datatype
>(32767), you can easely use the DATEADD(..) function..
Hi Andrea,
Eh? 32767 ?
I think you meant to write 2,147,483,647 here...
To Lucky:[vbcol=seagreen]
Can you tell me how long a "tick" lasts, and what the starting point for
the meaasurement is? And what is the exact date and time corresponding
to the 632557193645506250 value in your post?
Hugo Kornelis, SQL Server MVP
|||hi Hugo
Hugo Kornelis wrote:
> On Tue, 4 Apr 2006 19:18:30 +0200, Andrea Montanari wrote:
>
> Hi Andrea,
> Eh? 32767 ?
> I think you meant to write 2,147,483,647 here...
oopsss.. just working with vb6 these days and the relative "int" dimension..
LOL.. I apologise ..
thank you for poiting it out..
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.18.0 - DbaMgr ver 0.62.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply

Friday, February 24, 2012

Beta Data Conversion

I have a data file in Beta 2 version, but now I've already uninstalled the
beta version and installed a new Release Version of SQLServer 2005. Does
anybody know how to convert the data file to be usable in SQLServer 2005?Jeffry
Are you talking about .MDF datafile? If you are , have you tried to attach
the file? There are two system stored procedures as sp_detach_db,
sp_attach_db
"Jeffrey Kam" <Jeffrey Kam@.discussions.microsoft.com> wrote in message
news:913ABCEF-F02C-44A2-B9C0-881A7452D331@.microsoft.com...
>I have a data file in Beta 2 version, but now I've already uninstalled the
> beta version and installed a new Release Version of SQLServer 2005. Does
> anybody know how to convert the data file to be usable in SQLServer 2005?|||i tried to attach directly but it said it doesn't support beta version
"Uri Dimant" wrote:
> Jeffry
> Are you talking about .MDF datafile? If you are , have you tried to attach
> the file? There are two system stored procedures as sp_detach_db,
> sp_attach_db
>
>
>
> "Jeffrey Kam" <Jeffrey Kam@.discussions.microsoft.com> wrote in message
> news:913ABCEF-F02C-44A2-B9C0-881A7452D331@.microsoft.com...
> >I have a data file in Beta 2 version, but now I've already uninstalled the
> > beta version and installed a new Release Version of SQLServer 2005. Does
> > anybody know how to convert the data file to be usable in SQLServer 2005?
>
>|||Yep, I see. Probably RESTORE command will not work as well.
Do you have still BETA CD to install it and transfer the data ?
Unfortanutally I have no idea (if above does not work) how to restore the
data
"Jeffrey Kam" <JeffreyKam@.discussions.microsoft.com> wrote in message
news:EE6DD8D9-FE2E-4566-903F-05F3748C2E7A@.microsoft.com...
>i tried to attach directly but it said it doesn't support beta version
> "Uri Dimant" wrote:
>> Jeffry
>> Are you talking about .MDF datafile? If you are , have you tried to
>> attach
>> the file? There are two system stored procedures as sp_detach_db,
>> sp_attach_db
>>
>>
>>
>> "Jeffrey Kam" <Jeffrey Kam@.discussions.microsoft.com> wrote in message
>> news:913ABCEF-F02C-44A2-B9C0-881A7452D331@.microsoft.com...
>> >I have a data file in Beta 2 version, but now I've already uninstalled
>> >the
>> > beta version and installed a new Release Version of SQLServer 2005.
>> > Does
>> > anybody know how to convert the data file to be usable in SQLServer
>> > 2005?
>>|||Thank you for your reply
Sorry, I still couldn't find it. that's why I want a solution without setup
another Beta 2. Does Microsoft provide such tools?
"Uri Dimant" wrote:
> Yep, I see. Probably RESTORE command will not work as well.
> Do you have still BETA CD to install it and transfer the data ?
>
> Unfortanutally I have no idea (if above does not work) how to restore the
> data
>
> "Jeffrey Kam" <JeffreyKam@.discussions.microsoft.com> wrote in message
> news:EE6DD8D9-FE2E-4566-903F-05F3748C2E7A@.microsoft.com...
> >i tried to attach directly but it said it doesn't support beta version
> >
> > "Uri Dimant" wrote:
> >
> >> Jeffry
> >> Are you talking about .MDF datafile? If you are , have you tried to
> >> attach
> >> the file? There are two system stored procedures as sp_detach_db,
> >> sp_attach_db
> >>
> >>
> >>
> >>
> >>
> >>
> >> "Jeffrey Kam" <Jeffrey Kam@.discussions.microsoft.com> wrote in message
> >> news:913ABCEF-F02C-44A2-B9C0-881A7452D331@.microsoft.com...
> >> >I have a data file in Beta 2 version, but now I've already uninstalled
> >> >the
> >> > beta version and installed a new Release Version of SQLServer 2005.
> >> > Does
> >> > anybody know how to convert the data file to be usable in SQLServer
> >> > 2005?
> >>
> >>
> >>
>
>|||Hi
I am not aware of such tools , sorry
"Jeffrey Kam" <JeffreyKam@.discussions.microsoft.com> wrote in message
news:BF911B6B-A4F6-4740-8DBA-46C09EB9BF20@.microsoft.com...
> Thank you for your reply
> Sorry, I still couldn't find it. that's why I want a solution without
> setup
> another Beta 2. Does Microsoft provide such tools?
> "Uri Dimant" wrote:
>> Yep, I see. Probably RESTORE command will not work as well.
>> Do you have still BETA CD to install it and transfer the data ?
>>
>> Unfortanutally I have no idea (if above does not work) how to restore the
>> data
>>
>> "Jeffrey Kam" <JeffreyKam@.discussions.microsoft.com> wrote in message
>> news:EE6DD8D9-FE2E-4566-903F-05F3748C2E7A@.microsoft.com...
>> >i tried to attach directly but it said it doesn't support beta version
>> >
>> > "Uri Dimant" wrote:
>> >
>> >> Jeffry
>> >> Are you talking about .MDF datafile? If you are , have you tried to
>> >> attach
>> >> the file? There are two system stored procedures as sp_detach_db,
>> >> sp_attach_db
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> "Jeffrey Kam" <Jeffrey Kam@.discussions.microsoft.com> wrote in message
>> >> news:913ABCEF-F02C-44A2-B9C0-881A7452D331@.microsoft.com...
>> >> >I have a data file in Beta 2 version, but now I've already
>> >> >uninstalled
>> >> >the
>> >> > beta version and installed a new Release Version of SQLServer 2005.
>> >> > Does
>> >> > anybody know how to convert the data file to be usable in SQLServer
>> >> > 2005?
>> >>
>> >>
>> >>
>>

Beta Data Conversion

I have a data file in Beta 2 version, but now I've already uninstalled the
beta version and installed a new Release Version of SQLServer 2005. Does
anybody know how to convert the data file to be usable in SQLServer 2005?
Jeffry
Are you talking about .MDF datafile? If you are , have you tried to attach
the file? There are two system stored procedures as sp_detach_db,
sp_attach_db
"Jeffrey Kam" <Jeffrey Kam@.discussions.microsoft.com> wrote in message
news:913ABCEF-F02C-44A2-B9C0-881A7452D331@.microsoft.com...
>I have a data file in Beta 2 version, but now I've already uninstalled the
> beta version and installed a new Release Version of SQLServer 2005. Does
> anybody know how to convert the data file to be usable in SQLServer 2005?
|||i tried to attach directly but it said it doesn't support beta version
"Uri Dimant" wrote:

> Jeffry
> Are you talking about .MDF datafile? If you are , have you tried to attach
> the file? There are two system stored procedures as sp_detach_db,
> sp_attach_db
>
>
>
> "Jeffrey Kam" <Jeffrey Kam@.discussions.microsoft.com> wrote in message
> news:913ABCEF-F02C-44A2-B9C0-881A7452D331@.microsoft.com...
>
>
|||Yep, I see. Probably RESTORE command will not work as well.
Do you have still BETA CD to install it and transfer the data ?
Unfortanutally I have no idea (if above does not work) how to restore the
data
"Jeffrey Kam" <JeffreyKam@.discussions.microsoft.com> wrote in message
news:EE6DD8D9-FE2E-4566-903F-05F3748C2E7A@.microsoft.com...[vbcol=seagreen]
>i tried to attach directly but it said it doesn't support beta version
> "Uri Dimant" wrote:
|||Thank you for your reply
Sorry, I still couldn't find it. that's why I want a solution without setup
another Beta 2. Does Microsoft provide such tools?
"Uri Dimant" wrote:

> Yep, I see. Probably RESTORE command will not work as well.
> Do you have still BETA CD to install it and transfer the data ?
>
> Unfortanutally I have no idea (if above does not work) how to restore the
> data
>
> "Jeffrey Kam" <JeffreyKam@.discussions.microsoft.com> wrote in message
> news:EE6DD8D9-FE2E-4566-903F-05F3748C2E7A@.microsoft.com...
>
>
|||Hi
I am not aware of such tools , sorry
"Jeffrey Kam" <JeffreyKam@.discussions.microsoft.com> wrote in message
news:BF911B6B-A4F6-4740-8DBA-46C09EB9BF20@.microsoft.com...[vbcol=seagreen]
> Thank you for your reply
> Sorry, I still couldn't find it. that's why I want a solution without
> setup
> another Beta 2. Does Microsoft provide such tools?
> "Uri Dimant" wrote:

Beta Data Conversion

I have a data file in Beta 2 version, but now I've already uninstalled the
beta version and installed a new Release Version of SQLServer 2005. Does
anybody know how to convert the data file to be usable in SQLServer 2005?Jeffry
Are you talking about .MDF datafile? If you are , have you tried to attach
the file? There are two system stored procedures as sp_detach_db,
sp_attach_db
"Jeffrey Kam" <Jeffrey Kam@.discussions.microsoft.com> wrote in message
news:913ABCEF-F02C-44A2-B9C0-881A7452D331@.microsoft.com...
>I have a data file in Beta 2 version, but now I've already uninstalled the
> beta version and installed a new Release Version of SQLServer 2005. Does
> anybody know how to convert the data file to be usable in SQLServer 2005?|||i tried to attach directly but it said it doesn't support beta version
"Uri Dimant" wrote:

> Jeffry
> Are you talking about .MDF datafile? If you are , have you tried to attac
h
> the file? There are two system stored procedures as sp_detach_db,
> sp_attach_db
>
>
>
> "Jeffrey Kam" <Jeffrey Kam@.discussions.microsoft.com> wrote in message
> news:913ABCEF-F02C-44A2-B9C0-881A7452D331@.microsoft.com...
>
>|||Yep, I see. Probably RESTORE command will not work as well.
Do you have still BETA CD to install it and transfer the data ?
Unfortanutally I have no idea (if above does not work) how to restore the
data
"Jeffrey Kam" <JeffreyKam@.discussions.microsoft.com> wrote in message
news:EE6DD8D9-FE2E-4566-903F-05F3748C2E7A@.microsoft.com...[vbcol=seagreen]
>i tried to attach directly but it said it doesn't support beta version
> "Uri Dimant" wrote:
>|||Thank you for your reply
Sorry, I still couldn't find it. that's why I want a solution without setup
another Beta 2. Does Microsoft provide such tools?
"Uri Dimant" wrote:

> Yep, I see. Probably RESTORE command will not work as well.
> Do you have still BETA CD to install it and transfer the data ?
>
> Unfortanutally I have no idea (if above does not work) how to restore the
> data
>
> "Jeffrey Kam" <JeffreyKam@.discussions.microsoft.com> wrote in message
> news:EE6DD8D9-FE2E-4566-903F-05F3748C2E7A@.microsoft.com...
>
>|||Hi
I am not aware of such tools , sorry
"Jeffrey Kam" <JeffreyKam@.discussions.microsoft.com> wrote in message
news:BF911B6B-A4F6-4740-8DBA-46C09EB9BF20@.microsoft.com...[vbcol=seagreen]
> Thank you for your reply
> Sorry, I still couldn't find it. that's why I want a solution without
> setup
> another Beta 2. Does Microsoft provide such tools?
> "Uri Dimant" wrote:
>