In Sql Server we can convert text to number by use two properties.
If table column is VARCHAR and has all the numeric values in it, it can be retrieved as Integer using CAST or CONVERT function.
1. CAST
Please see example below:
SELECT CAST(YourVarcharCol AS INT) FROM Table
it mean you can convert text to number by use CAST then select field in table that you want to
select and assign data type.
2. CONVERT
SELECT CONVERT(INT, YourVarcharCol) FROM Table
Two properties have different in used.
so if you want which properties you msut see Syntax clearly.
No comments:
Post a Comment