check validity of cast before performing cast? 
Author Message
 check validity of cast before performing cast?

Hi,

is there a quick and easy way to check if cast will succeed or not?

I tried the following in a stored procedure:

...


..

the problem is that when it fails, the error still makes it way back to the

either a GUID, and INT, or some text, and I will perform a different search
in each case.


looks like a valid GUID, but I was hoping there was an easier way to check
without generating an exception.



Wed, 10 Sep 2003 07:50:51 GMT
 check validity of cast before performing cast?

    You could use functions like ISNUMERIC or ISDATE to validate data to
some extent. Or you will have to build your own depending on your
requirements. ISNUMERIC is not appropriate for all situations. For a routine
that shows how to validate a GUID value in a string, please follow this
link:

http://www.umachandar.com/technical/SQL70Scripts/Main28.htm

--
Umachandar Jayachandran
SQL Resources at http://www.umachandar.com/resources.htm
( Please reply only to newsgroup. )



Thu, 11 Sep 2003 11:25:00 GMT
 check validity of cast before performing cast?
Great - thanks!

Quote:
>     You could use functions like ISNUMERIC or ISDATE to validate data to
> some extent. Or you will have to build your own depending on your
> requirements. ISNUMERIC is not appropriate for all situations. For a
routine
> that shows how to validate a GUID value in a string, please follow this
> link:

> http://www.umachandar.com/technical/SQL70Scripts/Main28.htm

> --
> Umachandar Jayachandran
> SQL Resources at http://www.umachandar.com/resources.htm
> ( Please reply only to newsgroup. )



Fri, 12 Sep 2003 02:17:27 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. CREATE CAST requires immutable cast function?

2. CREATE CAST requires immutable cast function?

3. where clause cast fails despite use of isnumeric, other checks

4. CAST Error

5. CAST and CONVERT in SQL Server CE?

6. ODBC SQL Server Driver Invalid charater value for cast specification (0#)

7. Using Cast to convert Datetime to Int -loosing 2 days

8. CAST or Convert

9. Help with Cast Function and other DTS Problems

10. Convert/Cast Datetime

11. ORDER BY CAST( mycharcol AS integer )

12. Converting or Casting FLOAT to INT


 
Powered by phpBB® Forum Software