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

You want to implement the many-to-many relationship while designing tables. How would you do it?

0 Answers  


Which event (check constraints, foreign key, rule, trigger, primary key check) will be performed last for an integrity check?

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  


What is merge replication?

0 Answers  


How do you fine the performance tunning?

2 Answers   Accenture,






What is buffer cash in sql server?

0 Answers  


What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM table

17 Answers   HP,


What is snapshot replication?

0 Answers  


What is bcp? When does it used?

0 Answers  


Can we check locks in database? If so, how can we do this lock check?

0 Answers  


What will you do If the low Performance occurs?

2 Answers  


how many triggers you can have on a table? : Sql server database administration

0 Answers  


Categories