June 23, 2004 at 3:37 am
Hi,
In a stored procedure I need to report some datas in a file. So I use the command : EXEC master..xp_cmdshell 'echo ' + @msg + '>' + @file
My problem is:
If @file = 'log062304.txt', no problem. The file is in the directory 'C:\Winnt\system32'
But I need to generate a file with a longer name and in a different directory. But if @file = 'C:\files\log_pbs_062304.txt', it creates 3 different files : 'log_pbs_062304.txt', 'log_re' and 'log_rejet_230'...
Is it a problem with my procedure which is too fast for the xp_cmdshell ?
Thanks!
Oliver
June 23, 2004 at 3:25 pm
I have a number of jobs which perform file operations via xp_cmdshell and have never experienced anything like this. I would suggest that you take a long, hard look at your code. You might try placing a space before and after the '>' symbol.
Steve
June 24, 2004 at 12:58 am
It is perhaps also worth putting double quotes round the long filename.
This has solved problems on the earlier versions of windows for me before!
Dave.
June 24, 2004 at 1:07 am
Maybe you have special characters in @msg, especially ">" or "|", also "&&".
June 24, 2004 at 2:20 am
In fact, it happens when the length of my variable @file is more than 18 characters (for example : 'C:\log_00000015.txt').If it's less ('C:\log_0000001.txt'). , no problem. Strange...
My file doesn't contain special character ('|' ...). And my code is fine, I think.
June 24, 2004 at 3:52 am
Can you post your code?
Cheers,
- Mark
June 24, 2004 at 6:01 am
Thanks for your help !
My code was wrong : I have declared my variable @file as varchar and not as sysname.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply