SQL SERVER CAST CONVERSION FUNCTION
--alright viewers, we are going to look at the cast function to convert a number with decimals to integer
--we are using SQL SERVER 2012 SSMS.
--to enable predictive text known as intellisense press the following button above or press control & Q or Control +I
--to run a query press (F5) or the !Execute button above as follows
--here we go
--so first we will run the query to see what format the data currently looks like
--then we will use cast to convert it from having decimal places to not having decimal places
select p.ListPrice
from AdventureWorksDW2012.dbo.DimProduct as P;
--now let's get rid of the decimal places and convert the data type to integer
select CAST(P.listprice as int)
from AdventureWorksDW2012.dbo.DimProduct as P;
--you can see that the numbers are now in integer data type.
--that is it.
No comments:
Post a Comment