I think you are missing my point, so let me try and explain this another way.
When you run a DOS command, the operating system will look in the current folder to find the exe. If it's in the current folder, then good... it'll run it.
If the exe is not in the folder, then the operating system will look at the environment variable (named path) to find the exe. When you install SQL Server, it adds the path (where you install it to) to the path environment variable.
To see what I mean, on Windows XP....
Click Start -> Control Panel
Double Click System
Click the Advanced tab.
Click on 'Environment Variables'
In the 'System Variables' section, scroll down to Path.
Click once to highlight the path entry.
Click Edit.
You'll see this tiny little window that stores a really big string. It's usually best to copy/paste this to notepad or some other application that allows you see the whole thing. Mine looks like this...
[tt]C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\[/tt]
Each path is separated by a semi-colon. So, reformatting for human readability...
[tt]C:\WINDOWS\system32;
C:\WINDOWS;
C:\WINDOWS\system32\WBEM;
C:\Program Files\Microsoft SQL Server\80\Tools\BINN;
C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;
C:\Program Files\Microsoft SQL Server\90\Tools\binn\;
C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;
C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\[/tt]
Here's my point:
When you run an exe at a command prompt (without specifying the full path to the exe), the operating system will first check the current folder. If it's not there, it will look at the path environment variable. So, in my case, it will check C:\Windows\System32. If it finds the exe, it will run it. If not, it will check the next folder (C:\Windows). etc... It will continue checking all of the folders in the path variable. If it doesn't find it anywhere, it will not run the exe.
When you cannot run osql without specifying the whole path, it's because the path to the exe is not in the 'path' environment variable.
BTW... going to a command prompt and typing
path is an easier way to see what your 'Path environment variable' is.
Does this make sense now?
-George
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom