Wednesday, April 22, 2020

SQL - PRINT()


IF @@OPTIONS & 512 <> 0 
    PRINT N'This user has SET NOCOUNT turned ON.'; 
ELSE 
    PRINT N'This user has SET NOCOUNT turned OFF.'; 
GO 


-- Build the message text by concatenating 
-- strings and expressions. 
PRINT N'This message was printed on ' 
    + RTRIM(CAST(GETDATE() AS nvarchar(30))) 
    + N'.'; 
GO 
-- This example shows building the message text 
-- in a variable and then passing it to PRINT. 
-- This was required in SQL Server 7.0 or earlier. 
DECLARE @PrintMessage nvarchar(50); 
SET @PrintMessage = N'This message was printed on ' 
    + RTRIM(CAST(GETDATE() AS nvarchar(30))) 
    + N'.'; 
PRINT @PrintMessage; 
GO 

No comments:

Post a Comment