Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Varchar to Float Data Type

Status
Not open for further replies.

Robbs

Programmer
Joined
Jul 29, 2002
Messages
1
Location
CA
I have to convert several Varchar fields to Float data types in a SQL Server 2000 DB. What is the best way to do this? Can I just go into the table properties and change the data type? Will this automatically convert or is there a special SQL statement I should use. I am new to SQL Server and just wanted to seek the advice of others before doing this job. Thanks.
 

There are two function for casting and converting values ;

Select Cast('123' as float)

Select Convert(float , '123')

you can use update queries to change the data. you can also do this using change datatype in Enterprise Manager but if the length of varchar is greater then the float feild then it will loss the data and it will give you a warning when you perform this action. Even when you run the query then it will also give you the warning. Hence , you can use both ways.



Muhammad Essa Mughal
Software Engineer
essamughal@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top