Avatar of VIVEKANANDHAN_PERIASAMY
VIVEKANANDHAN_PERIASAMY
 asked on

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

Avatar of undefined
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 .
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Meir Rivkin

can we assume that "Event+number" keyword exists only once in each description in ticketdesc table?

cause i was thinking to use regex to find the event and id and use it to group them.
VIVEKANANDHAN_PERIASAMY

ASKER
Yes it will occur only once in the ticket
VIVEKANANDHAN_PERIASAMY

ASKER
Hello Experts,
Can anyone look into this question?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
VIVEKANANDHAN_PERIASAMY

ASKER
@admin:I don't see any improvement in this question
ASKER CERTIFIED SOLUTION
Kevin Cross

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
VIVEKANANDHAN_PERIASAMY

ASKER
i am getting the result as below

Event 1200      3
Event 1204      2
Event 1216      6
Event 17063      29
Event 18204      15
Event 208      18
Event 3041      24
Event 9002      3

now how can i give the substitute name instead of event id's ?
Meir Rivkin

do u have a table which maps event id to issue name or something like that?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
VIVEKANANDHAN_PERIASAMY

ASKER
nope, I have to give them a name in a hard code. If none of the code matches then it should go to unknown caption.
Meir Rivkin

so why not create another table in which u map the event id to issue name or description?
and in your sql query get the issue name via the event id.
VIVEKANANDHAN_PERIASAMY

ASKER
No this production Database, I won't be able to modify any chances :(

Okay , is it possible to get issues instead of Eventid?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Meir Rivkin

where are the issues names are located?
VIVEKANANDHAN_PERIASAMY

ASKER
It's present in the ticketdesc table

eg : ShortDesc: Event1479.MSSQLServer.SQLServer.Themirroringconneconh

You can see the attachment.

Insteadof getting eventid which you posted on ID: 37754502

It could be better if get "MSSQLServer.SQLServer.Themirroringconneconh..."

and group them by title name
Meir Rivkin

can u post the sql query here?
i'll make the change on top of that.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
VIVEKANANDHAN_PERIASAMY

ASKER
;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)
;
VIVEKANANDHAN_PERIASAMY

ASKER
Kindly Look into this problem