Programming in MS SQL Server 2012

Print Statement



Print statement is used to returns a user-defined message to the application or database users. A message string can be up to 8,000 characters long if it is a non-Unicode string, and 4,000 characters long if it is a Unicode string. The varchar(max) and nvarchar(max) data types are truncated to data types that are no more than varchar(8000) and nvarchar(4000). RAISEERROR can also be used to return messages.
Syntax

-- Syntax --

 

PRINT msg_str | @local_variable | string_expr


msg_str
msg_str is aa character string or Unicode string constant.
@local_variable
@local_variable is a variable of any valid character data type.
string_expr
string_expr is an expression that returns a string or concatenated literal values or function and variables data value.
The following example describes a PRINT statement.

-- Example 82 --

 

PRINT 'Welcome to the wonderful world of MS SQL Server'

 

PRINT 15 + 17

 

PRINT 'PREM' + ' ' + 'NATH' + ' ' + 'R.K'


Query Output Screen

* * * * *


Email Your Comment To AUTHOR