C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » Databases »

Datatype conversion in SQL Server


Posted Date: 26 Oct 2009    Resource Type: Articles    Category: Databases
Author: Venkatesan Prabu .JMember Level: Diamond    
Rating: 1 out of 5Points: 5



Let's see an interesting article on data type conversion,

select 8.5
-- The output is 8.5

[b]Using convert operator to convert a float value into an integer:[b]

select convert(int,8.9)

The above statement will try to convert the value into a possible integer. An equivalent of floor function.
[b]
Floor and ceiling functions in SQL Server:[b]

Floor function is used to get the lowest possible integer value from the given float value



select floor(8.9)
-- The output will be 8


Ceiling function is used to fetch the possible maximum value(next possible integer value) from the given float value.

select ceiling (8.9)
-- The output will be 9

select ceiling (8.4)
-- The output will be 9

[b]
Using Cast operator in the conversion process:
[b]
select cast (8.9 as int)

The above statement will try to cast the value into a possible integer. An equivalent to floor function.

References:
http://venkattechnicalblog.blogspot.com/2009/10/datatype-conversion-in-sql-server-float.html


Thanks and Regards,
Venkatesan Prabu .J


For more details, visit http://venkattechnicalblog.blogspot.com/2009/10/datatype-conversion-in-sql-server-float.html



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Datatype conversion in SQL Server  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Transfer Data using Select into
Previous Resource: Checking Sql server Database
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use