0

I'd like to create a custom warning for every change in table design (like the warning about tables affected). I created a trigger on database for ALTER_TABLE but i've no idea how to show an alert for that. Any idea?

SimoneG
  • 33
  • 1
  • 6
  • Possible duplicate of [RaiseError in SQL Server](https://stackoverflow.com/questions/15944630/raiseerror-in-sql-server) – underscore_d Oct 30 '17 at 14:49

1 Answers1

0

-- New message:

EXEC Sp_Addmessage 500021,
               10,
               'Custom message';
GO
RAISERROR(500021, 10, 1);

-- Replacement of Message:

EXEC Sp_Addmessage 500021,
               10,
               'Custom message... ',
               @Lang = 'us_english',
               @With_log = 'false',
               @Replace = 'replace';
GO
RAISERROR(500021, 10, 1);

-- Altering the message:

EXEC Sp_Altermessage 500021,
                 @Parameter = 'with_log',
                 @Parameter_value = 'true';

-- Dropping the message:

EXEC Sp_Dropmessage 500021;
SQL_M
  • 2,455
  • 2
  • 16
  • 30
  • And when you throw the error, you can use these messages. – SQL_M Oct 30 '17 at 14:50
  • @SimoneG if you found my answer useful, please accept it. Thanks. – SQL_M Oct 31 '17 at 08:46
  • As i wrote i want a message like the warning you have when you try to alter a table and this alter affects more tables. It's an alert that appears even in the design of SSMS. I want something like that – SimoneG Oct 31 '17 at 15:50