Skip to content
Advertisement

Looping through a column to check if a cast succeeds in SQL Server

I am trying to check if an entire column which is varchar and make sure it can be cast to float. I have a cursor portion like so:

For some reason, it is always returning 1. I already in a previous part of the cursor (not shown but above), verified that the column passed in (@ColumnName) is NOT NULL at any point.

I need to find out if all the CAST to FLOAT for @ColumnName are valid. The cursor loops through a table of columns bring in the FETCH @ColumnName one by one. What am I missing?

Advertisement

Answer

Easy:

For even better performance …

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement