how to substring the result

  • Hi,

    how i can extract only the processes name,and on another column the cpu usage resutls from this table.

    THX

    create table tbl_processes (proc_nammme nvarchar (500))

    go

    insert into tbl_processes values ('ProcessName:SqlWb |CpuUsage:5')

    insert into tbl_processes values ('ProcessName:CPU Burn-in |CpuUsage:99')

    insert into tbl_processes values ('ProcessName:cscript |CpuUsage:8')

  • Hope this helps:

    create table dbo.tbl_processes (proc_nammme nvarchar (500))

    go

    insert into dbo.tbl_processes values ('ProcessName:SqlWb |CpuUsage:5')

    insert into dbo.tbl_processes values ('ProcessName:CPU Burn-in |CpuUsage:99')

    insert into dbo.tbl_processes values ('ProcessName:cscript |CpuUsage:8')

    go

    select

    *,

    len('ProcessName:'),charindex('|', proc_nammme),len('CpuUsage:'),

    substring(proc_nammme, charindex('ProcessName:', proc_nammme) + 12, charindex('|', proc_nammme) - 13),

    substring(proc_nammme, charindex('CpuUsage:', proc_nammme) + 9, len(proc_nammme) - charindex('CpuUsage:', proc_nammme) + 9)

    from

    dbo.tbl_processes;

    go

  • thanks.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply