set up sql command

set up sql command

1
NewbieNewbie
1

    Aug 07, 2006#1

    I want to set up a tool using osql (the command line version of sql server's tsql) to run queries. Here is my command:

    "c:\Program Files\Microsoft SQL Server\80\Tools\Binn\osql.exe" -E -S servername -d dbname -Q "%sel" -w 1000

    Of course, "servername" and "dbname" are replaced appropriately.

    If I run this command in a DOS window (I'm running Win2k) and replace "%sel" with my sql query (which is simply "select count(*) from tableinfo"), it runs fine and I get back the result, which is the number 16 (there are 16 records).

    However, I haven't been able to get the result to appear in UE's output window. At most, when I highlight the query and run the tool, I get a messagebox that says "Operation completed successfully". That's fine, but I really want to see the result. Also, it wants to save the query in a text file, which I don't need. I just want to see the result.

    I have tried various combinations of option settings, with no luck (although with some settings it does put the command in the output window!) then I thought I'd see if someone in the forums can help me.

    Just for the record, besides the command as above, my tool settings are:
    Options - DOS Program; save active file; save all files first
    Output - Append to existing;Capture output;No replace

    6,688586
    Grand MasterGrand Master
    6,688586

      Aug 08, 2006#2

      I don't have installed Microsoft's SQL server. But according to the doc about the osql Utility, I think the parameter -r 1 could help.

      You should also try it with Show DOS Box enabled for the user tool in UltraEdit. And test it also with Alternate Capture Method in menu Advanced enabled/disabled.

      If the suggestions above do not help, run osql with a batch file like this one:

      @echo off
      "c:\Program Files\Microsoft SQL Server\80\Tools\Binn\osql.exe" -E -S servername -d dbname -Q "%1" -w 1000 -o "%temp%\osql_output.tmp"
      if exist "%temp%\osql_output.tmp" type "%temp%\osql_output.tmp"
      if exist "%temp%\osql_output.tmp" del "%temp%\osql_output.tmp" >nul


      In the user tool configuration of UltraEdit you have to specify only the batch file and the parameter "%sel".
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Aug 09, 2006#3

        This works for me using UE 12.10a. I am sending the output to a new window, but selecting "Output to List Box" works as well.

        "C:\...\osql.exe" -S server -d database -E -w 8092 -Q"%sel%"

        Replace "..." in path with your path to osql.exe.

        Options tab:
        DOS Program selected, nothing else checked.

        Output tab:
        Append to existing selected, Capture Output checked, and No Replace selected.