I want to export the table data of a database in sql server 2000 to a text file.Is there a way I can do it through some query or command line. If yes can anyone tell me the query. I would like to avoid doing it through UI.
For example, the Northwind database has the table Jane's Orders, which is owned by user Jane Doe. To bulk copy this table from the Northwind database to the Orders.txt file using the login Jane Doe and the password go dba, execute one of these commands:
I am able to get the customerid in the table to a .csv file correctly. I wanted to know is there a way I can get the column name also in this file so that the ids come below the column name in this case customerid
It's a pain in the pooper this is. There are a few ways. All are bodges to a greater or lesser degree. The easiest is to output a sort of specification file from the system tables if that is agreeable. If not, how high tech are you prepared to go?
You can hard code the names, but I'd advise against it. It's just not a very elegant solution.
But if you need a quick bandaid for this issue....
IF EXISTS (SELECT * FROM sysobjects WHERE name='vJobs') DROP VIEW [dbo].[vJobs]
CREATE VIEW [dbo].[vJobs]
SELECT 'job_id' AS job_id, 'job_desc' AS job_desc, 'min_lvl' AS min_lvl, 'max_lvl' AS max_lvl
SELECT CAST(job_id AS CHAR(6)), CAST(job_desc AS VARCHAR(60)), CAST(min_lvl AS VARCHAR(60)), CAST(max_lvl AS VARCHAR(60))