converting nvarchar to decimal in conn string

jmoe007

New Member
Joined
Mar 16, 2011
Messages
4
Hello All.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
Have a connection string that I use to pull data into an excel table.<o:p></o:p>
<o:p></o:p>
The issue I have is that one column (hours)is exporting as general but need it to come down as decimal<o:p></o:p>
<o:p></o:p>
I have tried to cast and convert, as well as *1.0 but it will not work.<o:p></o:p>
<o:p></o:p>
The column (hours) properties are nvarchar 255,null<o:p></o:p>
And have both single char and decimals<o:p></o:p>
5<o:p></o:p>
4.75<o:p></o:p>
8.5<o:p></o:p>
<o:p></o:p>
SELECT Convert(decimal(18,2), hours)*1.0 as hours<o:p></o:p>
FROM [dbLookups].[dbo].[TTDATA]<o:p></o:p>
full join dblookups.dbo.tblcolhierarchy<o:p></o:p>
on empid = empid<o:p></o:p>
<o:p></o:p>
How do I format it in my query so it will automatically come down as decimal?<o:p></o:p>
<o:p></o:p>
Thanks<o:p></o:p>
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,224,505
Messages
6,179,147
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top