PRINT in SQL is a statement used to return a message to the user, typically for debugging purposes or providing information during the execution of a stored procedure, function or trigger.
Example
Output
Explanation
In the example, DECLARE
is used to declare a variable @MyVariable
of type VARCHAR(50)
. The SET
statement is then used to assign the value ‘Hello, SQL Server!’ to this variable. Finally, the PRINT
statement is used to display the value of @MyVariable
, which results in outputting ‘Hello, SQL Server!’.
Example
Output
Explanation
In the example, DBMS_OUTPUT.PUT_LINE
is an Oracle procedure for sending a message to the console. The message ‘Hello, Oracle!’ is the string provided as an argument to DBMS_OUTPUT.PUT_LINE
. The BEGIN and END keywords are used to mark the start and end of the PL/SQL block containing the procedure call.