HI WELCOME TO KANSIRIS

FORMATMESSAGE Function in SQL Server 2016

Leave a Comment

In the previous versions of Sql server, this function was used to construct a message from strings located insys.messages.

FORMATMESSAGE statement is enhanced in SQL Server 2016 to enable supply your own string values.

Syntax: FORMATMESSAGE ( { msg_number  | ' msg_string ' } , [ param_value [ ,...n ] ] ) 

Example:-

DECLARE @ExampleMessage VARCHAR(150)

SET @ExampleMessage = FORMATMESSAGE('code-sample very popular from %s year and this is included in top %s best site','2013','5');

SELECT @ExampleMessage AS 'OUTPUT';     

OUTPUT
code-sample very popular from 2013 year and this is included in top 5 best site


SELECT FORMATMESSAGE('%s and  %s is the most popular tutorial sites for the develper', 'www.code-sample.com', 'www.code-view.com') AS Result;

Result

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.