by
0
9
3,790
1
Top 1% !
Popular
Famous
Tagged
Easy-to-find
Specified
Refined
OpenSource
MultiPlatform
Popularity: 3029th place
Architecturex86_64
LanguageSQL
LicenseMIT_X11
OSWindows
SQLServer2012
Windows VersionWindows7

Safe conversion of string to float in SQL Server 2012

This function allows a safe conversion of strings to float values.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/18528/Safe-conversion-of-string-to-float-in-SQ?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
CREATE FUNCTION [dbo].[isFloatTryConvertible] (@str nvarchar(70)) RETURNS bit WITH SCHEMABINDING AS BEGIN DECLARE @res bit = 0; IF (TRY_CONVERT(float, @str) IS NOT NULL) SET @res = 1; RETURN @res; END
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus