Setting Connection Options via T-SQL

  • Hi,

    I need to create a report that is tab delimited.

    I can achieve this by setting my connection options in Query Analyser.

    How could I do this as part of a stored Procedure. Such as 'set ........'

    Franknf


    Franknf

  • You cannot, that is an internal formating built by QA not by the data stream. Your client has to build it itself.

  • Thanks Antares686,

    I'll just have to add another step at the client side then.

    Franknf


    Franknf

  • You could try outputting your results as one long formatted column using the ASCII code for the tab character (I think it's 11).

    EG:

    
    
    SELECT Column1 + Char(11) + Column2 + etc...
    FROM Table

    You'll need to convert any numeric or datetime values to character formats.

    Hope this helps

    Phill Carter

    --------------------

    Colt 45 - the original point and click interface

    --------------------
    Colt 45 - the original point and click interface

  • Thanks phillcart,

    I didn't think of that.

    I think that's what I'll do.

    Franknf


    Franknf

  • horizontal tab = CHAR(9)


    * Noel

  • Thanks noeld, whats 11 ???

    Don't have my ASCII table handy.

    Hope this helps

    Phill Carter

    --------------------

    Colt 45 - the original point and click interface

    --------------------
    Colt 45 - the original point and click interface

  • VERTICAL tab = CHAR(11)


    * Noel

  • Well I'm impressed wasn't to bad a guess, at least it was something to do with tabbing

    Hope this helps

    Phill Carter

    --------------------

    Colt 45 - the original point and click interface

    --------------------
    Colt 45 - the original point and click interface

  • I have to admit that i like the tabbing idea but is going to be a little complicated is there are NULLs on the way and the number of columns is big.

    Any way I think is good to be creative!


    * Noel

  • Dealing with the nulls is actually fairly simple. Try something like the following...

    SELECT ISNULL(field1 + char(9),'') + ISNULL(field2 + char(9),'') + ISNULL(Lastfield,'') as DelimittedString

    Since a null added to anything will end up null it will not be added to your string 🙂

    Gary Johnson

    Microsoft Natural Language Group

    DBA, Sr. DB Engineer




    Gary Johnson
    Microsoft Natural Language Group
    DBA, Sr. DB Engineer

    This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.

  • If someone wanted to get really creative they could put togther a dynamic SQL statement based on syscolumns ...

    Pass in a table name, retrieve the object id and cursor through the column list adding in CONVERTS as appropriate.

    Hope this helps

    Phill Carter

    --------------------

    Colt 45 - the original point and click interface

    --------------------
    Colt 45 - the original point and click interface

Viewing 12 posts - 1 through 11 (of 11 total)

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