Click here to Skip to main content
Click here to Skip to main content

Tagged as

Go to top

Functionality as same Val() function in Access in Sql Server

, 21 Feb 2011
Rate this:
Please Sign up or sign in to vote.
DECLARE @doc VARCHAR(256)
 
DECLARE @doctemp VARCHAR(256)
 
SET @doc='467 . 1 2 3 4 .5 6 7 8 9 0 6hhjjjj'
 
SET @doc = replace(@doc,' ','')
 
SET @doctemp = substring(@doc,charindex('.',@doc)+1,len(@doc))
 
SET @doctemp = substring(@doctemp,charindex('.',@doctemp),len(@doctemp))
 
SET @doc = substring(@doc,1,patindex('%'+@doctemp+'%',@doc)-1)
 
SELECT CASE
 
    WHEN @doc LIKE '[0-9.]%'
 
    THEN CAST(SUBSTRING(@doc, 1, PATINDEX('%[^0-9.]%', @doc+' ') - 1) AS FLOAT)
 
    ELSE 0
 
END

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Vivek.Net
Software Developer (Senior) Accenture
India India
I am a Dot Net Developer working in MNC. I am interested to learn new technologies. I am always trying to improve my skills.
 
MCTS:ASP.NET 3.5
MCTS:WCF 3.5

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 21 Feb 2011
Article Copyright 2011 by Vivek.Net
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid