Displays a message on the message window of the database server.
PRINT format-string [, arg-list]
CREATE PROCEDURE print_test AS PRINT 'Procedure called successfully'
This statement returns the string “Procedure called successfully” to the client:
EXECUTE print_test
DECLARE @var1 INT, @var2 INT SELECT @var1 = 3, @var2 = 5 PRINT 'Variable 1 = %1!, Variable 2 = %2!', @var1, @var2
CREATE procedure DBA.login_check() begin // Allow a maximum of 3 concurrent connections IF( db_property('ConnCount') > 3 ) then raiserror 28000 'User %1! is not allowed to connect -- there are already %2! users logged on', current user, cast(db_property('ConnCount') as int)-1; ELSE call sp_login_environment; end if; end go grant execute on DBA.login_check to PUBLIC go set option PUBLIC.Login_procedure='DBA.login_check' go
For an alternate way to disallow connections, use the LOGIN_PROCEDURE option or the sp_iqmodifylogin system stored procedure.
The PRINT statement returns a message to the client window if you are connected from an Open Client application or JDBC application. If you are connected from an Embedded SQL or ODBC application, the message displays on the database server window.
The format string can contain placeholders for the arguments in the optional argument list. These placeholders are of the form %nn!, where nn is an integer between 1 and 20.