Take the 2-minute tour ×
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.

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

1 Answer 1

up vote 3 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.