Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ZenRoe
Starting Member
14 Posts |
Posted - 2008-06-18 : 03:42:29
|
| Hi all,In one of my UDF I use the following functions:..... and len(@int_date) = 4 and isnumeric(substring(@int_date,5,6)) = 1when I use the function I getOnly functions and extended stored procedures can be executed from within a function.Yes, when I comment the two lines the function works fine. Ehm.... why can't I use these functions in my function ?Thanks: Peter |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-18 : 04:06:23
|
Both of them cannot be true.First case: LEN(@param) = 4Second case: SUBSTRING(@param, 5, 6) does not exists if len(@param) = 4.Tell us what you want to do instead and maybe we can help you. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
ZenRoe
Starting Member
14 Posts |
Posted - 2008-06-18 : 04:15:37
|
| Basically I wanna make sure, the length of the string is 4 and numeric.However, meanwhile I figured out the problem: The input value was NULL which causedMSSQL to stumble. I now filter out the nulls before calling the function and everythingworks just fine now. The exception message thrown by MSSQL is a bit weirdo !Greetings to Sweden ! |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-18 : 04:25:15
|
[code]DECLARE @params table (d varchar(20))insert @paramsselect null union allselect '12321311' union allselect '3123' union allselect '234g'SELECT d, CASE WHEN LEN(ISNULL(d, '')) = 4 AND d NOT LIKE '%[^0-9]%' THEN 'Valid' ELSE 'Invalid' ENDfrom @params[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|