Skip to content
Advertisement

Filter msdb.dbo.sysjobsteps.command into seperate columns

I am trying to split the msdb.dbo.sysjobsteps.command column into separate columns to show the following information:

  • folder
  • project
  • dtx package

A small sample of my data is below:

I have tried to use the substring method, however I cannot seem to get the starting and ending number of the substring.

My aim is for the following in a ssms table:

enter image description here

Advertisement

Answer

You can use transform your data to xml to perform a “split” on backslashes and then you can extract only the data you need with an XQuery using the value() xml method (more info here on MS Docs).

In the following code I created a mock table called @tmp with your data:

This is the final result of the previous command:

enter image description here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement