Remove Column Header "text" from sp_helptext

  • I want to avoid generating Column Header "Text" when sp_helptext is used.

    This is done in Text Mode of QueryAnalyser.

    If there is way , suggest a way which can do this.

  • I guess there is an option in QA as well as in SSMS to enable/disable column headers display in results window.

    --Ramesh


  • thanks for the reply,

    i am aware of the option, wanted to know if we can do the same via programmatically so that we do not have to toggle on/off the setting.

    some query or script.

  • Hi

    Try this

    [font="Courier New"]

    SET NOCOUNT ON

    DECLARE @definition TABLE (id INT IDENTITY, line NVARCHAR(MAX))

    INSERT INTO @definition

       EXECUTE sp_helptext 'sp_test'

    DECLARE @id INT

    DECLARE @line NVARCHAR(MAX)

    WHILE EXISTS (SELECT TOP 1 * FROM @definition)

    BEGIN

       SELECT TOP(1) @id = id, @line = line FROM @definition ORDER BY id

      

       PRINT @line

      

       DELETE FROM @definition WHERE id = @id

    END[/font]

    Greets

    Flo

  • excellent workaround to overcome a problem.

    thanks very much,

    However one thing, as i said from the previos post, we can change it manually from the Query Options by checking/unchecking the

    "Include Column Headers in the ResultSet".

    Is there a way we can do this or change any Query Options via sql script.

  • Hi

    No that's not possible via SQL. The SSMS is only a client which transports information between you and your SQL Server. The SQL will not be executed in SSMS; only in SQL Server Engine.

    Greets

    Flo

  • Ok, That's very kind of you to share the solution and information.

    I will be shortly sharing the uitlity script which i was preparing and this thing was coming in way.

  • yet another method:

    SQLCMD -H-1

    1> exec sp_helptext sp_procname

    2> go

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

  • Off topic

    Wow... I'm currently starring at my previous posting.

    SQL scripts look quiet funny if created with SQLPrettifyer since forum update this today. 😀

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply