September 15, 2006 at 8:20 am
All,
When i'm running an osql command to output to a txt file, the file is writen to the server itself. Is there a way to direct it to a workstation iso the sql server?
Thanks
September 15, 2006 at 10:18 pm
Yep... write to a UNC instead of a file/path...
The server must have write privs, as well.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 18, 2006 at 5:15 am
Is there a way to simulate the "query analyzer" result options where you can choose to have the result send to a file. This way i d'ont need to tamper with sercurity and access rights.
I'm doing my devlopment from a workstation as well and "query analizer" saves the result file to my workstation. I would like to do the same from a tsql command.
Any solution?
Thanks
Serge
September 18, 2006 at 5:23 am
On which machine do you run your osql command?
_____________
Code for TallyGenerator
September 18, 2006 at 6:00 am
On may local workstation.
this command :
DECLARE @cmd VARCHAR(255)
SET @cmd = 'osql -E /Q "SELECT GETDATE()" /o \\AS-B-CLI-000\c:\temp\test2.csv'
EXEC master..xp_cmdshell @cmd
will generate error:
output
Cannot open output file - \\AS-B-CLI-000\c:\temp\test2.csv
No such file or directory
being "AS-b-CLI-000" my worksation. Reason for error is propably access rights as you mentioned before.
When a leave the workstationpath out of the command the file is writen on the sql server.
I hope this makes thing clearer.
Serge
September 18, 2006 at 6:23 am
So, you run the command on server. In server environment. With all its sequrity rights.
And what you expect?
What you are trying to do is calling your local town phone number being in another town ot even in another country.
Want to call you town - dial long distance access code, that means set rights to access your local folder from server.
Don't wanna mess with codes - go to your town and make your call, that means run osql command from your local machine. But because you need to retrieve data from server you need to have rights to access SQL server from your local machine.
And where did you see such kind of file reference: \\AS-B-CLI-000\c:\temp\test2.csv ?
I'm afraid it not gonna work in any way in any environment.
_____________
Code for TallyGenerator
September 18, 2006 at 6:55 am
\\AS-B-CLI-000\c:\temp\test2.csv is an invalid UNC name
you need to replace the c: with a share name
eg \\AS-B-CLI-000\mysharename\temp\test2.csv
but SQL will require the neccessary rights to the share
You could use c$, which is a hidden share but is restricted to Administrators
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply