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?



Is it possible to create a stored procedure that runs a query and outputs the results to a text fi..

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

Post New Answer

More SQL Server Interview Questions

What is Self Join?

4 Answers  


What is SQL Server?

0 Answers   Atos Origin,


What is sql collation?

0 Answers  


Explain couple pf features of SQL server

2 Answers  


Delete duplicate rows without using rowid.

0 Answers   Nagarro,


Explain SELF JOIN ?

3 Answers   ADP,


Suppose you want to implement the one-to-one relationships while designing tables. How would you do it?

0 Answers  


Tell me what is normalization? Explain different forms of normalization?

0 Answers  


Define clusters?

0 Answers  


What is the preferred way to create a clustered and non-clustered index? Which index should you create first the clustered or non-clustered?

0 Answers  


Explain mixed authentication mode of sql server?

0 Answers  


how can do you the system monitoring?

1 Answers  


Categories