Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2007-05-11 : 18:00:56
|
| I have already created the output file using the exec master..xp_cmdshell and all the fields are working based on the format.Now the problem which I have is all the files I generate should have a header with the file name(8 in length)and while using bcp I was not able to create the header.Is there any way to append this value to the first line of the output text file that's getting created. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
|
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2007-05-11 : 18:25:15
|
| This is using the column header for the data retreived but in my case Iam not retrieving the column names.I just want to create a header fo each file which I create using the BCP.The header is just the file name and rest all the values from row 2 will be the data retreived through BCP |
 |
|
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2007-05-11 : 19:31:42
|
| I used DECLARE @cmd sysname, @var sysnameSET @var = 'testworld'SET @cmd = 'echo ' + @var + '>> \\fildev01\Archive\Target\test.txt'EXEC master..xp_cmdshell @cmdBut this is getting appended to the last row but I want this to be the first line as a header |
 |
|
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2007-05-12 : 18:11:28
|
| I tried creating another file with a header and merged this 2 file likecopy newtest1.txt + test.txt newtest1.txt but the problem here is the end of file character is available when I merge it from test.txt and that will be a problem.If I can remove that character then it can be a work around.Please somebody help |
 |
|
|
|
|
|