I'm no C# guru, found this code on the web when looking for a way to try_parse in earlier versions of sql (2005).
Expand|Select|Wrap|Line Numbers
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data.SqlTypes;
- using Microsoft.SqlServer.Server;
- namespace ClassLibrary1
- {
- public class Class1
- {
- [SqlFunction]
- public static SqlDouble TryParseDouble(SqlString str)
- {
- Double d;
- bool success = Double.TryParse(str, out d);
- if (!success)
- return SqlDouble.Null;
- return new SqlDouble(d);
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- Error 1 The best overloaded method match for 'double.TryParse(string, out double)' has some invalid arguments c:\xxxxx\Class1.cs 16 32 ClassLibrary1
- Error 2 Argument 1: cannot convert from 'System.Data.SqlTypes.SqlString' to 'string' c:\xxxxx\Class1.cs 16 48 ClassLibrary1
Thanks!