Dear All,
How to store Column name and Row name in text File using SQL Server? I am using following query for create Text file in the local driver for getting data from table.I need to display Column name in the text File . How to do this?
DECLARE @FileName varchar(50),@bcpCommand varchar(2000)
SET @FileName = REPLACE('D:\authors_'+CONVERT(char(8),GETDATE(),1)+'.txt','/','-')
SET @bcpCommand = 'bcp "SELECT sono as [SO No] FROM DB Name..tbl_ss" queryout "'
SET @bcpCommand = @bcpCommand + @FileName + '" -U sa -P pw -c'
EXEC master..xp_cmdshell @bcpCommand
PRINT @bcpCommand