Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How to change the name of a database user?

951


Explain how many types of relationship?

1016


Write a sql query to display the current date?

1083


What gets stored inside msdb database?

1240


How do I get Report Builder to generate a parameter that can be set by users viewing the report?

148


What is the difference between online clustering and Offline clustering?

2406


Can you tell me some of the common replication dmv's and their use? : sql server replication

914


Mention the uses of stored procedures.

962


What are the different types of sql server replication? : sql server replication

1251


What are sql servers used for?

1035


How can I get data from a database on another server?

981


Tell me the use of keyword with encryption. Create a store procedure with encryption?

996


What is the importance of concurrency control?

1218


What are the requirements to use odbc connections in php scripts?

1104


What are trace flags?

1020