Click here to Skip to main content
11,631,896 members (71,572 online)
Click here to Skip to main content

Tagged as

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

, 21 Feb 2011 CPOL 6.1K 2
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

You may also be interested in...

Comments and Discussions

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