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 error and transaction handling in sql server?
Does the order of columns in update statements matter?
How many triggers you can have on a table?
What is a DBMS, query, SQL?
What is mssql?
List some case manipulation functions in sql?
Explain optimistic and pessimistic concurrency?
How to create “dependant” parameter “make, model, year”
How to modify existing triggers using "alter trigger"?
How to concatenate two strings in SQL Server.
What do you understand by a stored procedure?
What is format parameter in ssrs?
1.what is the diff between nolock optimizer and read uncommitted isolation? 2.what is the diff between revoke and deny? 3.what is percieved down time? 4.whether password protection are required for backups?if yes why?if no why? 5.what is fill factor? 6.what is cost analysis? 7.what is mean by piece meal restore? 8.what is 'rowguidcol'? 9.impersonate permission? 10.what is selectivity?
If no size is defined while creating the database, what size will the database have?
Can we install sql server 2016 on windows 7?