Need to search the eventid in the column and need to give a appropriate name
I have column called ticketdesc where it contain may information, I tried using charindex function, the problem using this function is ,I am not able to find proper start place.There are around 1 millions types of ticket description,so it's hard to analysis.
I like to have the SQL query,where it will search for a keyword of event id's alone and need to group as per the events Id's and need to give proper name.
Expected Output:
Problem total
Back up Issue	50
Mirroring 		10
.
.
.
.
.
.
so on Sample-colum.txt
Microsoft SQL ServerMicrosoft SQL Server 2005Microsoft SQL Server 2008SQL
Last Comment
VIVEKANANDHAN_PERIASAMY
8/22/2022 - Mon
Meir Rivkin
i didn't quite understand your requirement.
you want to loop through the information in this column and group all the entries based on keyword event id.
for instance, all the entries in the column which has the word "database" in it, group them under proper name and return it back.
is that what u mean?
Meir Rivkin
do u have mapping table which maps the keyqord to look and the proper name you with to apply?
for example:
Table: MappingNames
Keyword | Title
-----------------------------
database | DB Issues
network | networking Issues
and so on.
VIVEKANANDHAN_PERIASAMY
ASKER
No we don't have mapping table.
If the eventid Event1479 then it's mirroring issue.
Keyword will be given by us
Like from tale if i get the o/p like
column count
eventid 1479 2
evebtid 3041 10
the final output will be
column count ---------------mirroring&backup.. so on will be given by us.
mirroring issue 2
backe up failed 10
I will analysis the eventid's and will give own caption for that .
;WITH tickets(Ticketdesc) AS (
SELECT 'ShortDesc: Event1479.MSSQLServer.SQLServer.Themirroringconneconh...' UNION ALL
SELECT 'Event1454.MSSQLSERVER.Applicaon..MSSQLSERVER...' UNION ALL
SELECT 'Event1454.MSSQLSERVER.Applicaon.SQLServer2K8.DBMPAGEU...' UNION ALL
SELECT 'Event17063.MSSQLSERVER.Applicaon..17063Gener...' UNION ALL
SELECT 'Control error.'
)
SELECT EventID=STUFF(LEFT(Eventdesc, PATINDEX('%[.]%', Eventdesc)-1), 6, 0, ' ')
, CountOfEvents=COUNT(*)
FROM (
SELECT Eventdesc=SUBSTRING(Ticketdesc, PATINDEX('%Event[0-9]%', Ticketdesc), 15)
FROM tickets
WHERE PATINDEX('%Event[0-9]%', Ticketdesc) > 0
) derived
GROUP BY LEFT(Eventdesc, PATINDEX('%[.]%', Eventdesc)-1)
;
you want to loop through the information in this column and group all the entries based on keyword event id.
for instance, all the entries in the column which has the word "database" in it, group them under proper name and return it back.
is that what u mean?