Is there a T-SQL command....

  • Hi all,

    I dont know whether there is a command to disply results in text mode instead of grid mode in Query Analyser. I have searched a lot to know it in BOL, but no use. I hope, there is way to display results in text using t-sql commands.

    Thanks in advance.

    madhusudannaidugundapaneni


    Madhu

  • Displaying results in text or a grid is a 'client thing', and nothing to do with the server part of SQL Server.

    As far as I know, the only way is to use the Query analyser menu, or set text as the default using the Results tab of the Tools/Options menu.

  • Right click in the query pane and select "Results in Text"

    You'll probably also need to go into Tools->Options->Results tab

    and set the Maximum characters per column to 8000 so it doesn't

    truncate the results

  • Thanks for your replies. As I already specified, I want it with the help of t-sql commands.

    madhusudannaidugundapaneni


    Madhu

  • Don't think it is possible to set the format in Query Analyzer to 'Text' from a T-SQL command.

    You can set the default for any new connection to display results in text using the Tools->Options menu. On the Results tab, set the first option.

    Can you give us some clues as to why you want to do this?

  • As it is part of a stored procedure. My procedure displays contents of a text file which is in C drive. If I view those contents in text mode, I would reduce some manual work. And one more thing is I want to automate the procedure.

    madhusudannaidugundapaneni


    Madhu

  • Like ianscarlett said, that is a CLIENT thing. The results are not returned in a grid, nor in a 'text' mode.

    They are returned as a recordset (I presume).

    So, suppose someone uses another tool than Query Analyzer to execute the procedure, he will not see the difference.

    You should never use Query Analyzer as a 'client' tool for users. It is good for a DBA and for developpers, but a 'normal' user should not want to use QA for any interaction with the database.

  • use cursor, the display the values with

    print command

  • That solution is OK for QA. But remember that if anyone executes the procedure outside of QA, nothing is returned! Not to mention the performance hit due to the use of a cursor.

  • Cast and concatenate the results into a single varchar column and return that

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

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