title: Different Way for assigning value to a variable in SQL
body: <p>Can i write the following query in other way?</p>
  
  <pre><code>ALTER PROC Proc_AssetManagement_SubscriptionCheck @IMEINumber NVARCHAR(100)
  ,@PhoneNo NVARCHAR(200)
  ,@SIMNo NVARCHAR(100)
  ,@Id INT
  ,@Message NVARCHAR(MAX) OUTPUT
  AS
  BEGIN
  
  DECLARE @SimMessage NVARCHAR(200) = ''
  DECLARE @PhoneMessage NVARCHAR(200) = ''
  SET @Message = ''
  
  SELECT @Message = (
          CASE 
              WHEN COUNT(IMEINumber) &gt; 0
                  THEN ('IMEI Already Exists\n')
              ELSE ' '
              END
          )
  FROM tblAssetSubscriptionDetails
  WHERE AssetMgmtId &lt;&gt; @Id
      AND (IMEINumber = @IMEINumber)
  
  SELECT @PhoneMessage = (
          CASE 
              WHEN COUNT(PhoneNo) &gt; 0
                  THEN ('PhoneNo Already Exists\n')
              ELSE ' '
              END
          )
  FROM tblAssetSubscriptionDetails
  WHERE AssetMgmtId &lt;&gt; @Id
      AND (PhoneNo = @PhoneNo)
  
  SELECT @SimMessage = (
          CASE 
              WHEN COUNT(SimNo) &gt; 0
                  THEN ('SimNo Already Exists')
              ELSE ' '
              END
          )
  FROM tblAssetSubscriptionDetails
  WHERE AssetMgmtId &lt;&gt; @Id
      AND (SIMNo = @SIMNo)
  
  SET @Message = @Message + '' + @PhoneMessage + '' + @SimMessage
  END
  </code></pre>
  
  <p>I want to reduce the number of queries and want to get the message in single query rather then 3 different queries. Can i do it? If so then how? 
  My purpose is that I want to get a message formed like this.</p>
  
  <p>If IMEINumber is found in the table then it will show IMEI number already exists.
  If SIm No is found in the table along with IMEINumber then it will show IMEI number already exists\nSim No already exists and so on...</p>