How to find and get last value and remaining value [Resolved]

Posted by Jayakumars under .NET Framework on 3/4/2016 | Points: 10 | Views : 253 | Status : [Member] [MVP] | Replies : 2
-- My string is like this
-- ABCD/1947E/1234/1500
-- I need split last part and remaining part
-- I need 2 column like this

---FIRST COLUMN this ABCD/1947E/1234/
-- Second column 1500

--No need string position because suppose change some string before 1500 so

Mark as Answer if its helpful to you


Posted by: Professionaluser on: 3/4/2016 [Member] [MVP] Bronze | Points: 50


declare @var  varchar(100) ='ABCD/1234/1547/00001'
SELECT LEFT(@Var, LEN(@Var)-CHARINDEX( '/', REVERSE(@Var ))+1) Part1
, RIGHT(@var , CHARINDEX( '/', REVERSE(@Var ))-1) as Part2

Part1 Part2
ABCD/1234/1547/ 00001

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Paulnevinthomas on: 3/4/2016 [Member] Starter | Points: 25

You should be able to use the fillnull command.

sorucetype="foo" | ....|chart max(S1) as S1 by foo,time | fillnull value=200 S1

Replaces null values with a specified value. Null values are field values that are missing in a particular result but present in another result. Use fillnull to replace null field values with a string. If you do not specify a field list, fillnull replaces all null values with 0 (the default) or a user-supplied string.

fillnull [value=string] [<field-list>]

Optional arguments
Syntax: <field>...
Description: One or more fields, delimited with a space. If not specified, fillnull is applied to all fields.
Datatype: value=<string>
Description: Specify a string value to replace null values.

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response