Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 22nd, 2005, 01:58 AM
Authorized User
 
Join Date: Jun 2005
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!

 
Old July 22nd, 2005, 09:34 AM
Registered User
 
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old July 23rd, 2005, 06:44 PM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
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 ] )

 
Old July 24th, 2005, 06:02 PM
Authorized User
 
Join Date: Jun 2005
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!






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.