Skip to content

Commit

Permalink
Create Gather-sys.messages-SCOM.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
x-limitless-x authored Jul 14, 2022
1 parent 4dd11d2 commit 8fbb580
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions SQL Queries/Gather-sys.messages-SCOM.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#Original Author: Benign Sage
#Original Location: https://github.com/benignsage/sqlserver-sys.messages-scom/blob/master/script1.sql
#Original Post: https://www.sqlalliance.com/viewtopic.php?f=8&t=3
SELECT
m.message_id,
m.language_id,
l.name,
m.severity,
m.is_event_logged,
m.text,
'EXEC sp_addmessage @msgnum = ' + CONVERT(VARCHAR, m.message_id) + ', @msgtext = N''' + REPLACE(m.text, '''', '''''')
+ ''', @severity = ' + CONVERT(VARCHAR, m.severity) + ', @lang = ''' + l.name + ''', @with_log = ' +
(
SELECT
CASE is_event_logged
WHEN 1 THEN
'True'
ELSE
'False'
END
FROM
sys.syslanguages
WHERE
lcid = m.language_id
) + ', @replace = ''REPLACE''' AS SQLCommand
FROM
sys.messages AS m
INNER JOIN sys.syslanguages AS l
ON m.language_id = l.lcid
WHERE
message_id >= 777000000

0 comments on commit 8fbb580

Please sign in to comment.