cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Andy_Sismey
Champion Sweeper III
Hi,

Is there a way in SQL to select certain values from a Description column and display just those values in a new column or the same Column, for example I have a table containing CVE information, I'm trying to just identify the CVE Values so this :

"Microsoft Windows Multiple Type1 Font Parsing Remote Code Execution Vulnerabilities (CVE-2020-1020 and CVE-2020-0938)"

Becomes :

"CVE-2020-1020,CVE-2020-0938"

Cheers

A
2 REPLIES 2
Andy_Sismey
Champion Sweeper III
Hi Hendrik.VE,

That was really helpful and I'm nearly there with your help, the query I have so far is

SELECT Name,(SELECT REPLACE(REPLACE(SUBSTRING(dbo.[DB].Name, CHARINDEX('(CVE-', dbo.[DB].Name), CHARINDEX(')', dbo.[DB].Name)), '(', ''), ')', '') AS Expr1) AS CVE
FROM dbo.[DB]


The only issue I am getting a few records which have text before as below, which I cant seem to remove the text before?

OLE Automation Underflow Vulnerability CVE-2011-0658
Null Session Cookie Crash Vulnerability CVE 2011-2012
CVE-2021-40730
CVE-2021-40493
CVE-2021-40486

Cheers

A
Hendrik_VE
Champion Sweeper III
Hi Andy,

should be quite easy to implement using a combination of substring and charindex calculations in SQL.

So something like
Select
Substring( tblBlabla.description, charindex('(CVE',tblBlabla.description), charindex (')',tblBlabla.description ) )

But a little bit more complicated like that 🙂

A bit of trial and error and it should work.

Oh and a 'replace' to replace the AND with ,