Get Decimal and Value Seprated

SQL SERVER 2005 and above supports Function Call ParseName(), Function splits value when "." is used in given value



Declare @Value as Numeric(13,3)
SET @Value  = 1000.250
Select ParseName(@Value,2) Precision, ParseName(@Value,1) Scale

Output
Precision = 1000
Scale  = 250

Now we try same with String Value.


Declare @Value as Varchar(500)

SET @Value  = 'Switin.Kotian.Mumbai.switinkotian@gmail'

Select ParseName(@Value,4) Name, ParseName(@Value,3) SurName,ParseName(@Value,2) Place, ParseName(@Value,1) Email

Output
Name :- Switin
SurName : Kotian
Place :  Mumbai
Email : switinkotian@gmail

After seeing this we can get value from string and break into columns.
Counting starts from Highest value to lowest seprated by "." .


                          4      3          2                   1              
SET @Value  = 'Switin.Kotian.Mumbai.switinkotian@gmail'

Comments

Popular posts from this blog

Shared / Static Class in vb.net/C#

Text was truncated or one or more characters had no match in the target code page.". (SQL Server Import and Export Wizard)

Xamarin Forms : PopUp Page with RG.Plugins.Popup