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
What is the difference between local and global temporary tables?
what exactly sql injuction.how to overcome.....
How many columns can exist together per table?
How do I get to sql server configuration manager?
How can you find out which stored procedures are recompiling?
Write a program to fetch first 10 records from a file?
How to rebuild all indexes on a single table?
What do you mean by an execution plan? Why is it used? How would you view it?
Help!!!!!!!!!!!! My database has gone offline, it is highlighted as 'Suspect'. Foolishly, i haven't got a recent back up. Is there a way of quickly restoring the database? Thank you
How can I change procedure name in sql server?
What is sql server replication? : sql server replication
What is command parameter in ssrs?
What is the difference between NOROW and LOCKROW?
Why use “in” clause in sql server?
How are the unique and primary key constraints different?