Anson Anson - 4 months ago 8
SQL Question

sql sql server 2012 does not print message

I write the following code to print message:

declare @NT1 int
set @NT1 =(SELECT CompanyID FROM dbo.CompanyInfo where CompanyID = 101)

if @NT1> 101

print 'Good'


After execute this script , I get the following message
Command(s) completed successfully.

I should get message 'Good' after executing the above script. How do I print message?

Thanks

Answer

One solution:

declare @NT1 int
set @NT1 =(SELECT   CompanyID  FROM [FPMDB-MSIT].dbo.CompanyInfo where CompanyID = 101)

if @NT1 = 101

print 'Good'