dalearyous
[H]ard|Gawd
- Joined
- Jun 21, 2008
- Messages
- 1,922
why doesn't this work?
just to explain, there is a value that the user is supposed to fill in with number, not characters but every now and then some idiot does fill it in with characters and it breaks a bunch of sorting scripts.
in my example, column1 is varchar(15). most of you will want to reply "just change it so it doesn't accept characters or just change it from varchar to int in the table structure. well, short answer is i can't. so i just want to cast or convert any characters in that column to int.
i feel like my query should work but it fails to convert to int. thoughts?
Code:
SELECT cast(column1 as int)
FROM database;
just to explain, there is a value that the user is supposed to fill in with number, not characters but every now and then some idiot does fill it in with characters and it breaks a bunch of sorting scripts.
in my example, column1 is varchar(15). most of you will want to reply "just change it so it doesn't accept characters or just change it from varchar to int in the table structure. well, short answer is i can't. so i just want to cast or convert any characters in that column to int.
i feel like my query should work but it fails to convert to int. thoughts?