I have an SQL query. One of the columns returns a string. But sometimes returns "" nothing. but most times it's a number like "2383" but as a string. I need the returned value to be converted from a string to an integer. So from 2383 to 2383. I used the old * by 1 trick. However I found when I run the query it errors with those that have "" blanks. Is there a better way to convert the string to a number? or another way to handle this?
Hey Sarah I tried to to_number doesnt work. Maybe I got the db type wrong it could be ms SQL server. Not Oracle.
For Ms SQL, try cast or convert https://docs.microsoft.com/en-us/sq...nd-convert-transact-sql?view=sql-server-ver15
Ok. By the way I did try to_number before even making the original post. I will try convert and cast. I haven't used those before much. I will try and let you know how it goes.
How do you get the database wrong? You don't accidentally end up with either of those two, I might be out of date but those aren't run of the mill databases like MySQL.
We recently did a db migration i think so that's how. anyways i'm not very good and not as good as others on this forum. Sorry. I have used CAST(string AS INT) and it worked thank you thread close.
All fixed so that's good. I've had some fun in the past where we've had read access to mainframes and writing reports on them.