Skip to content

PRINT

DECLARE @MyVariable VARCHAR(50)
SET @MyVariable = 'Hello, SQL Server!'
PRINT @MyVariable
Hello, SQL Server!

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!’.