Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 converting nvarchar to decimal in conn string

Author  Topic 

JMOE
Starting Member

4 Posts

Posted - 2011-05-01 : 19:08:29
Hello All.

Have a connection string that I use to pull data into an excel table.

The issue I have is that one column (hours)is exporting as general but need it to come down as decimal

I have tried to cast and convert, as well as *1.0 but it will not work.

The column (hours) properties are nvarchar 255,null
And have both single char and decimals
5
4.75
8.5

SELECT Convert(decimal(18,2), hours)*1.0 as hours
FROM [dbLookups].[dbo].[TTDATA]
full join dblookups.dbo.tblcolhierarchy
on empid = empid

How do I format it in my query so it will automatically come down as decimal?

Thanks

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-05-01 : 21:39:15
try convert the result to string


select convert(varchar(20), convert(decimal(18,2), hours))
from . . .



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -