Hi,
I am trying to erase a file using xp_cmdshell and my filename is stored in a variable. Can you tell me how I allow xp_cmdshell to interpret my filename instead of taking it as a literal?
Thanks in advaince!
-------------------------------------------------------
set @filename =...
If I have executed a stored procedure to create a trace file, how is it that at a later point I identify the TraceID of this newly created file so that I can stop and close the trace?
If I try to delete a .trc file and it hasn't been closed, I get a sharing violation message, which is expected...
To mrdenny,
Thanks! You solved the mystery!
The placement of N is what made all the difference:
This will work:
set @filename = N'c:\path\to\file'
exec @rv = sp_trace_create @rs output, 0,@filename
This will NOT work:
set @filename = 'c:\path\to\file'
exec @rv = sp_trace_create @rs...
To NoCoolHandle,
Your supplied code doesn't really work. Although you get a Return Code = 0, this return code applies to TraceID, but doesn't apply to the success of creating the FILE .
If you rerun your code and ask for a return value of file creation, you will get Return Code = 12 (File...
I assume your suggestion of:
output, 0, N'@filename
you really mean to end the quote after filename as:
'@filename' - otherwise, it won't compile.
I also tried your suggestion of Nvarchar(255), but to no avail.
Have you ever used sp_Trace_create, passing in variables?
P.S. How do I color...
I'm trying to pass in a varible to a stored proc and I'm not having success.
If I don't use a variable, a trace file is created. If I use a variable, the trace file is not created. Any idea why?
This works when I hard code the drive and filename:
exec @rs = sp_trace_create @traceid output...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.