This script export the data in text file from sql server 2005 tables. This script containing stored procedure which required four input parameters as follows :-
@DBName - Pass database name
@TableName - Pass Table name for export
@FilePath - pass valid path with file name
@Separator - pass field separator(if you pass null then it will take ',' as default separator)
In this article i have used bcp command which is required some xm_cmdshell configuration enabled in your server.
To enable to xp_cmdshell on your server execute following script :
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE