Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a SQL Function that returns an Integer as the Output. I need to execute it via sqlcmd and I only want to get it's integer output.

However right now I'm getting back this type of output:

------------ 
      25 

<1 rows affected> 

How can I get my output to be just 25 with no other text.

Here's the Call I'm using:

sqlcmd -S MyServer\Instance -d SQLAdmin -Q "SELECT dbo.UDF_INT_Get_Status ('INT_02')"  
share|improve this question
up vote 2 down vote accepted

You are looking for the headers option of sqlcmd. Adding -h -1 will suppress header information.

sqlcmd -S MyServer\Instance -d SQLAdmin -Q "SELECT dbo.UDF_INT_Get_Status ('INT_02')" -h -1
share|improve this answer
    
Did the trick. Thanks. – Todd Nov 17 '11 at 2:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.