Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 22nd, 2005, 01:58 AM
Authorized User
 
Join Date: Jun 2005
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Covert CHAR to Float

Hi everyone,

Anybody know how to convert CHAR to FLOAT? What is the syntax to do that? Plz help...
Thanks!

Reply With Quote
  #2 (permalink)  
Old July 22nd, 2005, 09:34 AM
Registered User
 
Join Date: Jul 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

declare @t char(2)
set @t='22'
select convert(float,@t)

Reply With Quote
  #3 (permalink)  
Old July 23rd, 2005, 06:44 PM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Wellington, FL , USA.
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You can use the CAST or CONVERT function to convert a char to a float.
CAST ( expression AS data_type )
or
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

Reply With Quote
  #4 (permalink)  
Old July 24th, 2005, 06:02 PM
Authorized User
 
Join Date: Jun 2005
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Nut if i want to change the data type in VIEW is it possible?
Or i must do it in the table?
When i try to use the CONVERT in view,
SELECT CONVERT ( FLOAT(20), [Min])
FROM wo_view

it just give me the error message -> Server: Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to float.

Please give me some advice!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Big challenge here! How to convert char* to char^? samiswt Visual C++ 2005 1 November 30th, 2007 09:09 PM
Invalid conversion from 'char*' to 'char' deuxmio C++ Programming 3 December 8th, 2006 07:56 AM
Covert TIF to PDF Zeus_Man .NET Framework 1.x 0 October 4th, 2006 10:55 AM
Covert a tab dillemted file to excel bbradyva Excel VBA 0 October 21st, 2005 10:00 AM
How to Covert Excel to Text file as Database narendra_patil ASP.NET 1.x and 2.0 Application Design 1 July 20th, 2005 03:01 PM



All times are GMT -4. The time now is 05:51 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.