How to cast data types
Microsoft Net Framework

How to cast data types

The Cast() function is used to convert a data type variable or data from one data type to another data type.
 The Cast() function provides a data type to a dynamic parameter


For Example

There is four value and her data type is Varchar if we want add all values it is necessery to convert into Int 


 DECLARE @A varchar(10)
 DECLARE @B varchar(10)
 DECLARE @C varchar(10)
 DECLARE @D varchar(10)

 SET @A = 10
 SET @B = 20
 Set @C = 30
 set @D = 40

 Select Cast(@A as int) + CAST(@B AS int)+CAST(@C AS int)+CAST(@D AS int)TotalResult

 

Total Result = 100

 

 

Share This with your friend by choosing any social account


Upcoming Articles
You may also read following recent Post
Copyright Future Minutes © 2015- 2024 All Rights Reserved.   Terms of Service  |   Privacy Policy |  Contact US|  Pages|  Whats new?
Update on: Dec 20 2023 05:10 PM