Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Call sp without column headers.

Author  Topic 

SQLSoaker
Posting Yak Master

169 Posts

Posted - 2008-12-18 : 10:39:05
Hello,

Is it possible to call a stored procedure and have it not print the column headers?

exec my_SP @parm1 = 'xxx' @parm2 = 'xxx'

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-12-18 : 10:59:45
Since your sp only returns a table convert it to a table function. Then:

select header1+'', header2+'' from my_fn(@parm1, @parm2)
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-18 : 11:11:13
What?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

SQLSoaker
Posting Yak Master

169 Posts

Posted - 2008-12-18 : 11:14:42
quote:
Originally posted by hanbingl

Since your sp only returns a table convert it to a table function. Then:

select header1+'', header2+'' from my_fn(@parm1, @parm2)



Thank you hanbingl, I've tried this but I am getting an error.

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[FUNCTION_AGINGREPORT] (@DATA nvarchar(3), @ACCOUNT nvarchar(200))
RETURNS TABLE AS
RETURN
EXEC my_SP @dataareaid = @DATA, @accountnum = @ACCOUNT


Incorrect syntax near the keyword 'EXEC'.


Are you not allowed to call exec in the function?!?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-18 : 11:21:26
I am stumped...



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

SQLSoaker
Posting Yak Master

169 Posts

Posted - 2008-12-18 : 11:25:02
quote:
Originally posted by Peso

I am stumped...



E 12°55'05.63"
N 56°04'39.26"




Peso, I am trying to call my stored procedure without column headers on it.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-18 : 11:56:41
Why?
What is your objective?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

SQLSoaker
Posting Yak Master

169 Posts

Posted - 2008-12-18 : 12:27:50
quote:
Originally posted by Peso

Why?
What is your objective?



E 12°55'05.63"
N 56°04'39.26"




I have another stored procedure that calls this one and writes the results to a file and then sends out email with that data. The formatting in the email would look a lot nicer if I were to remove the column headers after the first exec to the stored procedure.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-18 : 12:56:57
CREATE TABLE #Temp

INSERT #Temp EXEC sp1
INSERT #Temp EXEC sp2

Send mail containing records in #Temp table...



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

SQLSoaker
Posting Yak Master

169 Posts

Posted - 2008-12-18 : 16:07:08
quote:
Originally posted by Peso

CREATE TABLE #Temp

INSERT #Temp EXEC sp1
INSERT #Temp EXEC sp2

Send mail containing records in #Temp table...



E 12°55'05.63"
N 56°04'39.26"




Yes but this will not eliminate the column headers...
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-19 : 00:43:01
It will eliminate the second set of column headers.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -