简体   繁体   中英

How to use Function inside a raiserror

This is what I have tried, but seems to be wrong.

CREATE PROCEDURE test_proc(@User VARCHAR = NULL)
AS
BEGIN

RAISERROR (Select F_GetAmandaMessage('SAMPLE_TEST_KEY',NULL,@User), 16, 1);

END;

Could you please guide me here

Should I store the result of the function in a variable first and then use that variable in the raiserror section?

You must use a message id, a string literal or a variable in RAISERROR

CREATE PROCEDURE test_proc(@User VARCHAR = NULL)
AS
BEGIN
DECLARE @Message varchar(128) = (
   SELECT F_GetAmandaMessage('SAMPLE_TEST_KEY', NULL, @User)
);

RAISERROR(@Message, 16, 1);

END;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM