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
Explain cursor as data base object?
What is the difference between substr and charindex in the sql server?
difference between Clustered index and non clustered index ?
What are the types of indexes?
What is the difference between count () and rowcount ()?
What is the syntax to execute the sys.dm_db_missing_index_details? : sql server database administration
What is data mart? : sql server analysis services, ssas
Describe the left outer join & right outer join. : sql server database administration
What are the advantages of user-defined functions over stored procedures in sql server?
Do you know how to store and query spatial data?
Define magic tables in sql server?
What are the limitations/drawbacks or ssrs 2008 r2?
How do you handle datasets larger than 50 gb?
What is hierarchy, what are its types and difference between them? : sql server analysis services, ssas
Is sql different from sql server?