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 |
What is the use of keyword with encryption.
How to connect PK and FK?
What is the basic functions for master, msdb, tempdb databases?
What are different types of database indexes?
What is the difference between stored procedure and functions?
Do you know what are the ways available in sql server to execute sql statements?
What is the difference between ‘having’ clause and a ‘where’ clause?
What is set nocount on?
How to Insert multiple rows with a single insert statement?
How to create a new login name in ms sql server?
What are the difference between “where” and “having” clause in sql server?
When would you use sql joins?
Oracle (3259)
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)