how to separate the mem into another column

  • Hi,

    i've this script that insert all "tasklist" into a table.

    i want that the Image Name will be in one column and the Mem Usage will be in another column but the Image Name next to the Mem Usage.

    How i do that?

    THX

    declare @tasklist table (taskname nvarchar (500))

    insert into @tasklist

    exec xp_cmdshell 'tasklist /fo list'

    delete from @tasklist where taskname IS NULL or taskname like 'Session Name:%' or taskname like 'Session#%' or taskname like 'PID:%'

    select * from @tasklist

  • You should probably just leave the default format and pick out the columns you need:

    DECLARE @tasklist TABLE (taskname NVARCHAR (500))

    INSERT INTO @tasklist

    EXEC xp_cmdshell 'tasklist'

    DELETE FROM @tasklist WHERE taskname IS NULL OR taskname = 'Image Name' OR taskname LIKE '%Mem Usage' OR taskname LIKE '===%'

    SELECT

    LEFT(taskname,25) AS 'Image Name'

    ,LTRIM(RTRIM(RIGHT(taskname,12))) AS 'Mem Usage'

    FROM

    @tasklist

    _______________________________________________________________________
    For better assistance in answering your questions, click here[/url]

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

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