title: Assigning function result to SQL variable and displaying
body: <p>Migrating asp.net code (VB.net) to use functions and subroutines as parameters.
  Using MS Server Management Studio to create said functions and subs.
  Would like to test the functions from within MS SMS before testing them via the web page.
  Here's an example.  Say I have a function called "dbo.getNumber"</p>
  
  <p>I'm trying to test it using the following:</p>
  
  <pre><code>USE [someDB]
  GO
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  declare @value int;
  
  select @value = dbo.getNumber;
  
  print @value;
  go
  </code></pre>
  
  <p>When I type F5 (to run the "query") it gives the following msg:</p>
  
  <p>"The name "dbo.getNumber" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted."</p>
  
  <p>The function dbo.getNumber was accepted just fine, btw.  (It's counting records of a database that meet certain criteria.)</p>
  
  <p>Hopefully you can infer from the non-working code what I am trying to do.</p>
  
  <p>How can I print the value of a function (for testing purposes) from within SMS?</p>
  
  <p>Correct solution as per James Johnson, below:</p>
  
  <pre><code>USE [someDB]
  GO
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  declare @value int;
  
  select @value = dbo.getNumber();
  
  print @value;
  go
  </code></pre>
  
  <p>Note the parens for the function invocation.
  Note also: intellisense in SMS underlines dbo.getNumber() as if it were an error, but running the query with F5 works and outputs the right result.</p>