Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using cast in insert statement

I am inserting some raw data into a table in MS SQL 2005 from excel. Some of these data are not formatted correctly ie the amount colum is formatteT as a number 12345 whereas i need to be like 123.45 so i use this CAST(TRANSACTION_HISTORY.AMOUNT AS decimal) / 100 to convert it correctly. However is there a way to use the cast in an insert statement??

thanks

like image 878
ANDREAS Avatar asked Feb 15 '11 11:02

ANDREAS


1 Answers

You can use CAST in any kind of statement(Insert, update, delete, select) where you use data.

Insert into table1 values( CAST(col1 as nvarchar(50)) )
like image 58
Sachin Shanbhag Avatar answered Sep 21 '22 06:09

Sachin Shanbhag