sql - Converting from varchar to numeric -
i have 2 columns latitude , longitude. should have been set them numeric upon importing fixed width file, not have time re-do process. i'm using sql server express , have use import wizard. there 92 columns.
anyways, using following code , getting error (shown below) when try change varchar(9) numeric (11,6). have modified settings can make changes names , datatypes. know using design feature in object explorer yield similar error. other ways around dilemma?
code:
alter table dbo.tablename alter column latitude numeric(11,6); error:
msg 8114, level 16, state 5, line 1
error converting data type varchar numeric.
just found following code:
alter table tablename alter column latitude float why did work, not previous?
you need find value. i'm not sure sql server express supports isnumeric(), 1 possibility:
select latitude tablename isnumeric(latitude) = 0; otherwise, can approximate like:
where latitude not '%[^0-9.]%' , latitude not '%.%.%'
Comments
Post a Comment