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 GUID in sql server?
How many categories of functions based their return modes?
What is the meaning of sql server?
How to delete database objects with "drop" statements in ms sql server?
What are transactions in sql?
Equi join and non equi join is possible with sql server?
After removing a table from database, what other related objects have to be dropped explicitly?
What is difference between cte and view?
What is a natural primary key?
What are various aggregate functions that are available?
What are functions in the sql server?
What are different types of raid levels?
Is it possible for a stored procedure to call itself or recursive stored procedure?
Describe in brief system database.
Distinguish between commit and rollback?