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 / 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 |
select empid empname from employee What is the result for the about query?
What is #temp and @table variable in SQL server?
How to create a store procedure with encryption?
what is an extended stored procedure? Can you instantiate a com object by using t-sql? : Sql server database administration
What is the security principal at the database level that represents your session?
What is difference between materialized view and view?
Difference between rowid and rownum in SQL?
What's the maximum size of a row?
what are file groups?
What are different types of statement?
What is the difference between coalesce() & isnull()?
Explain full-text indexing?
Oracle (3253)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)