May 27, 2015 at 8:45 am
HI Experts,
Found that, if I want to pass the string "select @@servername" in the print statement, it throws error as:=
Msg 1046, Level 15, State 1, Line 3
Subqueries are not allowed in this context. Only scalar expressions are allowed.
Msg 1046, Level 15, State 1, Line 28
Subqueries are not allowed in this context. Only scalar expressions are allowed.
declare @account_name nvarchar(400) = 'Mail Account';
IF exists (select * from msdb.dbo.sysmail_account where name = @account_name)
PRint 'Database Mail Account ' + quotename (@account_name) + 'is already setup in the Server:= ' + (select @@servername);
What's wrong here? I mean why such restriction? In such queries results will be only 1 so it does not violate the SET operation. correct??
Thanks.
May 27, 2015 at 10:00 am
you don't need (select @@server) just use (@@server)
May 27, 2015 at 10:03 am
I guess the limitation comes because the development team has no interest on creating additional functionality to PRINT. Why would they?
May 27, 2015 at 10:06 am
Ohh you are right, using @@servername alone helps....thnx.. hard to remember everything together.
Thnx much!!!!!
Thanks.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply