Is it possible to create a stored procedure that runs a
query and outputs the results to a text file and allows me
to add extra delimeters and static field info. If so How?
Answer Posted / guest
SQL Server has no native command for outputting query
results to a file. You can use the extended
stored procedure xp_cmdshell and call isql (command-line
SQL) with your query and output the results to a file. Any
delimiters would need to be part of the SELECT string:
DECLARE @isqlString varchar(255)
SELECT @isqlString = 'isql -Q "SELECT DateCol FROM
NorthwindTest.dbo.Test" -E -o C:\Results.txt'
EXEC master..xp_cmdshell @isqlString
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How to change the name of a database user?
Explain how many types of relationship?
Write a sql query to display the current date?
What gets stored inside msdb database?
How do I get Report Builder to generate a parameter that can be set by users viewing the report?
What is the difference between online clustering and Offline clustering?
Can you tell me some of the common replication dmv's and their use? : sql server replication
Mention the uses of stored procedures.
What are the different types of sql server replication? : sql server replication
What are sql servers used for?
How can I get data from a database on another server?
Tell me the use of keyword with encryption. Create a store procedure with encryption?
What is the importance of concurrency control?
What are the requirements to use odbc connections in php scripts?
What are trace flags?