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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Ok, here's a challenge

Author  Topic 

sbt1
Yak Posting Veteran

89 Posts

Posted - 2007-02-21 : 13:56:21
Or at least it is for me!

I need to retrieve records, and in doing so change one field from nvchar to it's value multiplied 8.0.

In other words, I'm reading a column which stores the fraction of a workday in hours (for instance, "0.25") as text. I need to return this value multiplied by 8 (in this case, 0.25 * 8 = 2.0) as nvchar.

Any ideas? Thanks!

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2007-02-21 : 14:01:39
You need to return this value to WHAT? A front end? A report?

Do the multiplication and CAST to nvarchar there.

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2007-02-21 : 14:01:58
Somthing like:

SELECT CAST(CAST(@MyVar AS FLOAT) * 8.0 AS VARCHAR)



-Ryan
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-21 : 14:35:57
SELECT STR(@MyVar * 8.0, 10, 2) ???


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-02-21 : 16:31:21
btw, it's not a good idea to store numbers in char-type columns if you need to do arithmetic with them.

if it's a float, use a float.


www.elsasoft.org
Go to Top of Page
   

- Advertisement -