DHPBilcare
asked on
Export OSQL Query Result to a Test File
I have the following OSQL command which I need to run.
My quesiton is how do I export this result into a CSV file?
Use clintrial
SELECT [PatientID], [PackNo]
FROM Subject_Treatment_Visits INNER JOIN Trials ON
Subject_Treatment_Visits.T rialID = Trials.TrialID
Where protocoldesc = '00001'
Go
My quesiton is how do I export this result into a CSV file?
Use clintrial
SELECT [PatientID], [PackNo]
FROM Subject_Treatment_Visits INNER JOIN Trials ON
Subject_Treatment_Visits.T
Where protocoldesc = '00001'
Go
ASKER
We have a validated system that is using using Microsoft SQL Server Desktop Engine.
Therefroe I need to run the query from the command promt using osql.
I dont have any frontend user interface utility I can use on this server.
Thus I need to add the export command to the query in my first post.
Therefroe I need to run the query from the command promt using osql.
I dont have any frontend user interface utility I can use on this server.
Thus I need to add the export command to the query in my first post.
Then use SQLCMD instead of OSQL (old stuff).
sqlcmd -S ServerName -E -i FileName -o OutputFile
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In SSMS right-click on database name, Task, Export Data...
Follow the wizard and in place of table name just paste the query.