Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
MSSQL NVARCHAR to INT conversions
--Sql Server 2014 Express Edition --Batches are separated by 'go' select @@version as 'sql server version'; -- variants with nvarchar to int conversion -- select origin nvarchar column type select convert(nvarchar(50),'2.54'); -- select directly converted float from origin nvarchar column type -- with dot as decimal separator select convert(float, convert(nvarchar(50),'2.54')); --cast float to int select cast (convert(float, convert(nvarchar(50),'2.54')) as int) ; --float to int by floor, cast to int select cast( floor (convert(float, convert(nvarchar(50),'2.54')) ) as int) ; --float to int by ceiling, cast to int select ceiling (convert(float, convert(nvarchar(50),'2.54')) ) ; --float to int rounded to x places select round (convert(float, convert(nvarchar(50),'2.54')),1 ) ; --float to int rounded to 0 places, cast to int select cast(round (convert(float, convert(nvarchar(50),'2.54')),0 ) as int) ; --possible use with nvarch column as data origin --select cast( floor (convert(float, MyNVARCHARColumn) ) as int) ; -- try variants with negative number!
run
|
edit
|
history
|
help
0
Demo
Cursor (procedural while)
q
prince46
Department revenue pivot
Company DB
Task_6_Final
Xml Excercise 3
Hack_this
OFFSET FETCH Clause